MakeSampleToken creates and returns a encoded JWT token that has been signed with the specified cryptographic key.
(c jwt.Claims, method jwt.SigningMethod, key any)
| 34 | |
| 35 | // MakeSampleToken creates and returns a encoded JWT token that has been signed with the specified cryptographic key. |
| 36 | func MakeSampleToken(c jwt.Claims, method jwt.SigningMethod, key any) string { |
| 37 | token := jwt.NewWithClaims(method, c) |
| 38 | s, e := token.SignedString(key) |
| 39 | |
| 40 | if e != nil { |
| 41 | panic(e.Error()) |
| 42 | } |
| 43 | |
| 44 | return s |
| 45 | } |
| 46 | |
| 47 | func LoadECPrivateKeyFromDisk(location string) crypto.PrivateKey { |
| 48 | keyData, e := os.ReadFile(location) |