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

Function getRefreshJwt

edgraph/access.go:261–273  ·  view source on GitHub ↗

getRefreshJwt constructs a refresh jwt with the given user id, namespace and expiration ttl specified by worker.Config.RefreshJwtTtl

(userId string, namespace uint64)

Source from the content-addressed store, hash-verified

259// getRefreshJwt constructs a refresh jwt with the given user id, namespace and expiration ttl
260// specified by worker.Config.RefreshJwtTtl
261func getRefreshJwt(userId string, namespace uint64) (string, error) {
262 token := jwt.NewWithClaims(worker.Config.AclJwtAlg, jwt.MapClaims{
263 "userid": userId,
264 "namespace": namespace,
265 "exp": time.Now().Add(worker.Config.RefreshJwtTtl).Unix(),
266 })
267
268 jwtString, err := token.SignedString(x.MaybeKeyToBytes(worker.Config.AclSecretKey))
269 if err != nil {
270 return "", errors.Errorf("unable to encode jwt to string: %v", err)
271 }
272 return jwtString, nil
273}
274
275const queryUser = `
276 query search($userid: string, $password: string){

Callers 2

LoginMethod · 0.85
TestGetRefreshJwtFunction · 0.85

Calls 3

MaybeKeyToBytesFunction · 0.92
AddMethod · 0.45
ErrorfMethod · 0.45

Tested by 1

TestGetRefreshJwtFunction · 0.68