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

Method Extract

kitekey/kitekey.go:110–125  ·  view source on GitHub ↗

Extract is a keyFunc argument for jwt.Parse function.

(token *jwt.Token)

Source from the content-addressed store, hash-verified

108
109// Extract is a keyFunc argument for jwt.Parse function.
110func (e *Extractor) Extract(token *jwt.Token) (interface{}, error) {
111 e.Token = token
112
113 if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {
114 return nil, errors.New("invalid signing method")
115 }
116
117 claims, ok := token.Claims.(*KiteClaims)
118 if !ok {
119 return nil, fmt.Errorf("no kontrol key found")
120 }
121
122 e.Claims = claims
123
124 return jwt.ParseRSAPublicKeyFromPEM([]byte(claims.KontrolKey))
125}
126
127// GetKontrolKey is used as key getter func for jwt.Parse() function.
128func GetKontrolKey(token *jwt.Token) (interface{}, error) {

Callers 1

GetKontrolKeyFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected