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

Function MaybeKeyToBytes

x/jwt_helper.go:23–28  ·  view source on GitHub ↗

MaybeKeyToBytes converts the x.Sensitive type into []byte if the type of interface really is x.Sensitive. We keep the type x.Sensitive for private and public keys so that it doesn't get printed into the logs but the type the JWT library needs is []byte.

(k interface{})

Source from the content-addressed store, hash-verified

21// is x.Sensitive. We keep the type x.Sensitive for private and public keys so that it
22// doesn't get printed into the logs but the type the JWT library needs is []byte.
23func MaybeKeyToBytes(k interface{}) interface{} {
24 if kb, ok := k.(Sensitive); ok {
25 return []byte(kb)
26 }
27 return k
28}
29
30func ParseJWT(jwtStr string) (jwt.MapClaims, error) {
31 token, err := jwt.Parse(jwtStr, func(token *jwt.Token) (interface{}, error) {

Callers 5

getAccessJwtFunction · 0.92
getAccessJwtFunction · 0.92
getRefreshJwtFunction · 0.92
generateJWTFunction · 0.92
ParseJWTFunction · 0.85

Calls

no outgoing calls

Tested by 1

generateJWTFunction · 0.74