(tok *jwt.Token)
| 693 | } |
| 694 | |
| 695 | func validateClaims(tok *jwt.Token) (*Claims, error) { |
| 696 | if claims, ok := tok.Claims.(*Claims); ok { |
| 697 | if claims.Version != uint64(CurrentVersion) { |
| 698 | return nil, ErrInvalidVersion |
| 699 | } |
| 700 | if claims.IssuedAt == nil { |
| 701 | return nil, ErrMissingIssuedAt |
| 702 | } |
| 703 | if claims.NotBefore == nil { |
| 704 | return nil, ErrMissingNotBefore |
| 705 | } |
| 706 | |
| 707 | yearsHardLimit := time.Now().Add(5 /* years */ * 365 * 24 * time.Hour) |
| 708 | if claims.LicenseExpires == nil || claims.LicenseExpires.Time.After(yearsHardLimit) { |
| 709 | return nil, ErrMissingLicenseExpires |
| 710 | } |
| 711 | if claims.ExpiresAt == nil { |
| 712 | return nil, ErrMissingExp |
| 713 | } |
| 714 | if claims.AccountType == "" { |
| 715 | return nil, ErrMissingAccountType |
| 716 | } |
| 717 | if claims.AccountID == "" { |
| 718 | return nil, ErrMissingAccountID |
| 719 | } |
| 720 | return claims, nil |
| 721 | } |
| 722 | return nil, xerrors.New("unable to parse Claims") |
| 723 | } |
| 724 | |
| 725 | // ParseClaimsIgnoreNbf validates a raw JWT, but ignores `nbf` claim. If otherwise valid, it returns |
| 726 | // the claims. If unparsable or invalid, it returns an error. Ignoring the `nbf` (not before) is |
no test coverage detected