MCPcopy
hub / github.com/pocketbase/pocketbase / NewJWT

Function NewJWT

tools/security/jwt.go:46–58  ·  view source on GitHub ↗

NewJWT generates and returns new HS256 signed JWT.

(payload jwt.MapClaims, signingKey string, duration time.Duration)

Source from the content-addressed store, hash-verified

44
45// NewJWT generates and returns new HS256 signed JWT.
46func NewJWT(payload jwt.MapClaims, signingKey string, duration time.Duration) (string, error) {
47 claims := jwt.MapClaims{
48 // @todo consider with the refactoring to either remove the
49 // duration argument or make it always take precedence?
50 "exp": time.Now().Add(duration).Unix(),
51 }
52
53 for k, v := range payload {
54 claims[k] = v
55 }
56
57 return jwt.NewWithClaims(jwt.SigningMethodHS256, claims).SignedString([]byte(signingKey))
58}

Callers 7

TestNewJWTFunction · 0.92
newAuthTokenMethod · 0.92
NewVerificationTokenMethod · 0.92
NewPasswordResetTokenMethod · 0.92
NewEmailChangeTokenMethod · 0.92
NewFileTokenMethod · 0.92
BindSecurityFunction · 0.92

Calls 2

UnixMethod · 0.80
AddMethod · 0.45

Tested by 1

TestNewJWTFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…