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

Method Extract

kitetest/kitetest.go:146–165  ·  view source on GitHub ↗

Extract is a jwt.Keyfunc that extracts kite ID.

(tok *jwt.Token)

Source from the content-addressed store, hash-verified

144
145// Extract is a jwt.Keyfunc that extracts kite ID.
146func (te *TokenExtractor) Extract(tok *jwt.Token) (interface{}, error) {
147 var id string
148 var ok bool
149
150 switch claims := tok.Claims.(type) {
151 case *jwt.StandardClaims:
152 id, ok = claims.Id, true
153 case jwt.MapClaims:
154 id, ok = claims["jti"].(string)
155 }
156
157 if !ok || id == "" {
158 return nil, errors.New("no kite ID")
159 }
160
161 te.KiteID = id
162 te.Token = tok
163
164 return nil, errTokenExtractor
165}
166
167// ExtractKiteID extracts kite ID from the raw JWT token.
168func ExtractKiteID(token string) (string, error) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected