AuthenticateFromKiteKey authenticates user from kite key.
(r *Request)
| 273 | |
| 274 | // AuthenticateFromKiteKey authenticates user from kite key. |
| 275 | func (k *Kite) AuthenticateFromKiteKey(r *Request) error { |
| 276 | claims := &kitekey.KiteClaims{} |
| 277 | |
| 278 | token, err := jwt.ParseWithClaims(r.Auth.Key, claims, k.verify) |
| 279 | if err != nil { |
| 280 | return err |
| 281 | } |
| 282 | |
| 283 | if !token.Valid { |
| 284 | return errors.New("Invalid signature in kite key") |
| 285 | } |
| 286 | |
| 287 | if claims.Subject == "" { |
| 288 | return errors.New("token has no username") |
| 289 | } |
| 290 | |
| 291 | r.Username = claims.Subject |
| 292 | |
| 293 | return nil |
| 294 | } |
| 295 | |
| 296 | // AuthenticateSimpleKiteKey authenticates user from the given kite key and |
| 297 | // returns the authenticated username. It's the same as AuthenticateFromKiteKey |
nothing calls this directly
no outgoing calls
no test coverage detected