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

Function ExtractNamespaceFromJwt

x/jwt_helper.go:68–78  ·  view source on GitHub ↗
(jwtToken string)

Source from the content-addressed store, hash-verified

66}
67
68func ExtractNamespaceFromJwt(jwtToken string) (uint64, error) {
69 claims, err := ParseJWT(jwtToken)
70 if err != nil {
71 return 0, errors.Wrap(err, "extracting namespace from JWT")
72 }
73 namespace, ok := claims["namespace"].(float64)
74 if !ok {
75 return 0, errors.Errorf("namespace in claims is not valid:%v", namespace)
76 }
77 return uint64(namespace), nil
78}
79
80func ExtractNamespaceFrom(ctx context.Context) (uint64, error) {
81 jwtString, err := ExtractJwt(ctx)

Callers 2

AuditWebSocketsFunction · 0.92
ExtractNamespaceFromFunction · 0.85

Calls 2

ParseJWTFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected