ReadToken reads Kite Claims from JWT token and uses them to initialize Config.
(key *jwt.Token)
| 252 | |
| 253 | // ReadToken reads Kite Claims from JWT token and uses them to initialize Config. |
| 254 | func (c *Config) ReadToken(key *jwt.Token) error { |
| 255 | c.KiteKey = key.Raw |
| 256 | |
| 257 | claims, ok := key.Claims.(*kitekey.KiteClaims) |
| 258 | if !ok { |
| 259 | return errors.New("no claims found") |
| 260 | } |
| 261 | |
| 262 | c.Username = claims.Subject |
| 263 | c.KontrolUser = claims.Issuer |
| 264 | c.Id = claims.Id // jti is used for jwt's but let's also use it for kite ID |
| 265 | c.KontrolURL = claims.KontrolURL |
| 266 | c.KontrolKey = claims.KontrolKey |
| 267 | |
| 268 | return nil |
| 269 | } |
| 270 | |
| 271 | // Copy returns a new copy of the config object. |
| 272 | func (c *Config) Copy() *Config { |
no outgoing calls
no test coverage detected