Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( NotSciTokenError = errors.New("token is not a SciToken") TokenNotFoundError = errors.New("token not found") ScopeParseError = errors.New("unable to unmarshal and parse scope claim") GroupParseError = errors.New("unable to unmarshal wlcg.groups claim") VersionParseError = errors.New("unable to unmarshal ver claim") )
var AnyAudiences = []string{
"ANY",
"https://wlcg.cern.ch/jwt/v1/any",
}
AnyAudiences is the list of special wildcard audiences that a token can present to be used anywhere that otherwise accepts it.
"ANY" for SciTokens per https://scitokens.org/technical_docs/Claims.html.
"https://wlcg.cern.ch/jwt/v1/any" for WLCG tokens per https://zenodo.org/record/3460258.
Functions ¶
func GetGroups ¶
GetGroups parses the wlcg.groups claim and returns a list of all groups, or an empty list if the wlcg.groups claim is missing.
Returns GroupParseError if the wlcg.groups claim cannot be unmarshaled.
func GetVersion ¶ added in v0.2.0
GetVersion retrieves the ver claim, or an empty string if the claim is missing. For compatability it will also look for the wlcg.ver claim, which will be returned as "wlcg:$ver", where $ver is the value of the claim.
Types ¶
type Enforcer ¶
type Enforcer interface { AddIssuer(context.Context, string) error RequireAudience(string) error RequireScope(Scope) error RequireGroup(string) error RequireValidator(Validator) error Validate(SciToken, ...Validator) error ValidateToken([]byte, ...Validator) (SciToken, error) ValidateTokenString(string, ...Validator) (SciToken, error) ValidateTokenReader(io.Reader, ...Validator) (SciToken, error) ValidateTokenEnvironment(...Validator) (SciToken, error) ValidateTokenForm(url.Values, string, ...Validator) (SciToken, error) ValidateTokenHeader(http.Header, string, ...Validator) (SciToken, error) ValidateTokenRequest(*http.Request, ...Validator) (SciToken, error) }
Enforcer verifies that SciTokens https://scitokens.org are valid, from a certain issuer, and that they allow the requested resource.
func NewEnforcer ¶
NewEnforcer initializes a new enforcer for validating SciTokens from the provided issuer(s). Keys are fetched on-demand when a token is verified. Use NewEnforcerDaemon() for long-running processes.
func NewEnforcerDaemon ¶ added in v0.3.0
NewEnforcerDaemon initializes a new enforcer for validating SciTokens from the provided issuer(s), caching and refreshing keys periodically. The context object should be cancelled when the process is done with the enforcer.
type SciToken ¶
SciToken wraps a standard JWT token to add custom claims. Use NewSciToken() to wrap a jwt.Token and parse the custom claims.
type Scope ¶
Scope represents a token authorization scope, with optional path.
func GetScopes ¶
GetScopes parses the scope claim and returns a list of all scopes, or an empty list if the scope claim is missing.
Returns ScopeParseError if the scope claim cannot be unmarshaled or parsed.
func ParseScope ¶
ParseScope parses a scope string like AUTHZ[:PATH].
type TokenValidationError ¶
type TokenValidationError struct {
Err error
}
func (*TokenValidationError) Error ¶
func (e *TokenValidationError) Error() string
func (*TokenValidationError) Unwrap ¶
func (e *TokenValidationError) Unwrap() error
type Validator ¶
Validator describes the interface to validate a SciToken. Right now it's just a convenience wrapper around jwt.Validator.
func WithAudience ¶ added in v0.2.0
WithAudience validates that the token has the given audience or one of the supported "any" audiences, as defined in the AnyAudiences package variable.