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

Method parse

tokenrenewer.go:41–61  ·  view source on GitHub ↗

parse the token string and set

(tokenString string)

Source from the content-addressed store, hash-verified

39
40// parse the token string and set
41func (t *TokenRenewer) parse(tokenString string) error {
42 claims := &kitekey.KiteClaims{}
43
44 _, err := jwt.ParseWithClaims(tokenString, claims, t.localKite.RSAKey)
45 if err != nil {
46 valErr, ok := err.(*jwt.ValidationError)
47 if !ok {
48 return err
49 }
50
51 // do noy return for ValidationErrorSignatureValid. This is because we
52 // might asked for a kite who's public Key is different what we have.
53 // We still should be able to send them requests.
54 if (valErr.Errors & jwt.ValidationErrorSignatureInvalid) == 0 {
55 return fmt.Errorf("Cannot parse token: %s", err)
56 }
57 }
58
59 t.validUntil = time.Unix(claims.ExpiresAt, 0).UTC()
60 return nil
61}
62
63// RenewWhenExpires renews the token before it expires.
64func (t *TokenRenewer) RenewWhenExpires() {

Callers 2

NewTokenRenewerFunction · 0.95
renewTokenMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected