MCPcopy
hub / github.com/dgraph-io/dgraph / ExtractCustomClaims

Method ExtractCustomClaims

graphql/authorization/auth.go:308–325  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

306}
307
308func (a *AuthMeta) ExtractCustomClaims(ctx context.Context) (*CustomClaims, error) {
309 if a == nil {
310 return &CustomClaims{}, nil
311 }
312 // return CustomClaims containing jwt and authvariables.
313 md, _ := metadata.FromIncomingContext(ctx)
314 jwtToken := md.Get(string(AuthJwtCtxKey))
315 if len(jwtToken) == 0 {
316 if a.ClosedByDefault {
317 return &CustomClaims{}, fmt.Errorf("a valid JWT is required but was not provided")
318 }
319 return &CustomClaims{}, nil
320 }
321 if len(jwtToken) > 1 {
322 return nil, fmt.Errorf("invalid jwt auth token")
323 }
324 return a.validateJWTCustomClaims(jwtToken[0])
325}
326
327func GetJwtToken(ctx context.Context) string {
328 md, ok := metadata.FromIncomingContext(ctx)

Callers 14

AddSubscriberMethod · 0.80
RewriteMethod · 0.80
RewriteMethod · 0.80
FromMutationResultMethod · 0.80
FromMutationResultMethod · 0.80
RewriteMethod · 0.80
addDeleteFunction · 0.80
TestStringCustomClaimFunction · 0.80
TestAudienceClaimFunction · 0.80
TestJWTExpiryFunction · 0.80

Calls 3

GetMethod · 0.65
ErrorfMethod · 0.45

Tested by 5

TestStringCustomClaimFunction · 0.64
TestAudienceClaimFunction · 0.64
TestJWTExpiryFunction · 0.64