(ctx iris.Context)
| 30 | } |
| 31 | |
| 32 | func generateToken(ctx iris.Context) { |
| 33 | claims := fooClaims{ |
| 34 | Foo: "bar", |
| 35 | } |
| 36 | |
| 37 | // Sign and generate compact form token. |
| 38 | token, err := jwt.Sign(jwt.HS256, signatureSharedKey, claims, jwt.MaxAge(10*time.Minute)) |
| 39 | if err != nil { |
| 40 | ctx.StopWithStatus(iris.StatusInternalServerError) |
| 41 | return |
| 42 | } |
| 43 | |
| 44 | tokenString := string(token) // or jwt.BytesToString |
| 45 | ctx.HTML(`Token: ` + tokenString + `<br/><br/> |
| 46 | <a href="/protected?token=` + tokenString + `">/protected?token=` + tokenString + `</a>`) |
| 47 | } |
| 48 | |
| 49 | func protected(ctx iris.Context) { |
| 50 | // Extract the token, e.g. cookie, Authorization: Bearer $token |
nothing calls this directly
no test coverage detected
searching dependent graphs…