MCPcopy Create free account
hub / github.com/coder/coder / ParseRaw

Function ParseRaw

enterprise/coderd/license/license.go:658–678  ·  view source on GitHub ↗

ParseRaw consumes a license and returns the claims.

(l string, keys map[string]ed25519.PublicKey)

Source from the content-addressed store, hash-verified

656
657// ParseRaw consumes a license and returns the claims.
658func ParseRaw(l string, keys map[string]ed25519.PublicKey) (jwt.MapClaims, error) {
659 tok, err := jwt.Parse(
660 l,
661 keyFunc(keys),
662 jwt.WithValidMethods(ValidMethods),
663 )
664 if err != nil {
665 return nil, err
666 }
667 if claims, ok := tok.Claims.(jwt.MapClaims); ok && tok.Valid {
668 version, ok := claims[VersionClaim].(float64)
669 if !ok {
670 return nil, ErrInvalidVersion
671 }
672 if int64(version) != CurrentVersion {
673 return nil, ErrInvalidVersion
674 }
675 return claims, nil
676 }
677 return nil, xerrors.New("unable to parse Claims")
678}
679
680// ParseClaims validates a raw JWT, and if valid, returns the claims. If
681// unparsable or invalid, it returns an error

Callers 1

NewFunction · 0.92

Calls 3

keyFuncFunction · 0.85
ParseMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected