Extract is a jwt.Keyfunc that extracts kite ID.
(tok *jwt.Token)
| 144 | |
| 145 | // Extract is a jwt.Keyfunc that extracts kite ID. |
| 146 | func (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. |
| 168 | func ExtractKiteID(token string) (string, error) { |
nothing calls this directly
no outgoing calls
no test coverage detected