Functions for constructing CEL inputs. auth constructs a `google.rpc.context.AttributeContext.Auth` message.
(user string, claims map[string]string)
| 491 | |
| 492 | // auth constructs a `google.rpc.context.AttributeContext.Auth` message. |
| 493 | func auth(user string, claims map[string]string) *rpcpb.AttributeContext_Auth { |
| 494 | claimFields := make(map[string]*structpb.Value) |
| 495 | for k, v := range claims { |
| 496 | claimFields[k] = structpb.NewStringValue(v) |
| 497 | } |
| 498 | return &rpcpb.AttributeContext_Auth{ |
| 499 | Principal: user, |
| 500 | Claims: &structpb.Struct{Fields: claimFields}, |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | // request constructs a `google.rpc.context.AttributeContext.Request` message. |
| 505 | func request(auth *rpcpb.AttributeContext_Auth, t time.Time) map[string]any { |