(user string)
| 133 | } |
| 134 | |
| 135 | func 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 |
| 155 | func authHandler(w http.ResponseWriter, r *http.Request) { |
no test coverage detected