MCPcopy Create free account
hub / github.com/koding/kite / AuthenticateFromKiteKey

Method AuthenticateFromKiteKey

request.go:275–294  ·  view source on GitHub ↗

AuthenticateFromKiteKey authenticates user from kite key.

(r *Request)

Source from the content-addressed store, hash-verified

273
274// AuthenticateFromKiteKey authenticates user from kite key.
275func (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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected