MCPcopy Create free account
hub / github.com/cel-expr/cel-go / auth

Function auth

codelab/codelab.go:252–261  ·  view source on GitHub ↗

Functions for constructing CEL inputs. auth constructs a `google.rpc.context.AttributeContext.Auth` message.

(user string, claims map[string]string)

Source from the content-addressed store, hash-verified

250
251// auth constructs a `google.rpc.context.AttributeContext.Auth` message.
252func auth(user string, claims map[string]string) *rpcpb.AttributeContext_Auth {
253 claimFields := make(map[string]*structpb.Value)
254 for k, v := range claims {
255 claimFields[k] = structpb.NewStringValue(v)
256 }
257 return &rpcpb.AttributeContext_Auth{
258 Principal: user,
259 Claims: &structpb.Struct{Fields: claimFields},
260 }
261}
262
263// request constructs a `google.rpc.context.AttributeContext.Request` message.
264func request(auth *rpcpb.AttributeContext_Auth, t time.Time) map[string]any {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected