MCPcopy
hub / github.com/golang-jwt/jwt / createToken

Function createToken

http_example_test.go:135–152  ·  view source on GitHub ↗
(user string)

Source from the content-addressed store, hash-verified

133}
134
135func createToken(user string) (string, error) {
136 // create a signer for rsa 256
137 t := jwt.New(jwt.GetSigningMethod("RS256"))
138
139 // set our claims
140 t.Claims = &CustomClaimsExample{
141 jwt.RegisteredClaims{
142 // set the expire time
143 // see https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4
144 ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Minute * 1)),
145 },
146 "level1",
147 CustomerInfo{user, "human"},
148 }
149
150 // Creat token string
151 return t.SignedString(signKey)
152}
153
154// reads the form values, checks them and creates the token
155func authHandler(w http.ResponseWriter, r *http.Request) {

Callers 2

Example_useTokenViaHTTPFunction · 0.85
authHandlerFunction · 0.85

Calls 1

SignedStringMethod · 0.80

Tested by

no test coverage detected