MCPcopy Index your code
hub / github.com/koding/kite / AuthenticateSimpleKiteKey

Method AuthenticateSimpleKiteKey

request.go:299–316  ·  view source on GitHub ↗

AuthenticateSimpleKiteKey authenticates user from the given kite key and returns the authenticated username. It's the same as AuthenticateFromKiteKey but can be used without the need for a *kite.Request.

(key string)

Source from the content-addressed store, hash-verified

297// returns the authenticated username. It's the same as AuthenticateFromKiteKey
298// but can be used without the need for a *kite.Request.
299func (k *Kite) AuthenticateSimpleKiteKey(key string) (string, error) {
300 claims := &kitekey.KiteClaims{}
301
302 token, err := jwt.ParseWithClaims(key, claims, k.verify)
303 if err != nil {
304 return "", err
305 }
306
307 if !token.Valid {
308 return "", errors.New("Invalid signature in token")
309 }
310
311 if claims.Subject == "" {
312 return "", errors.New("token has no username")
313 }
314
315 return claims.Subject, nil
316}
317
318func (k *Kite) verifyInit() {
319 k.configMu.Lock()

Callers 1

HandleRegisterHTTPMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected