Documentation ¶
Index ¶
- func AddSignatureProvider(name string, provider SignatureProvider) error
- func AddValidationProvider(name string, provider ContentValidationProvider) error
- func RemoveSignatureProvider(name string)
- func RemoveValidationProvider(name string)
- func SetSignatureProvider(name string, provider SignatureProvider)
- func SetSigningAlgorithm(name string) error
- type AudienceValidationProvider
- type ContentValidationProvider
- type ExpiresValidationProvider
- type Header
- type IssuedAtValidationProvider
- type IssuerValidationProvider
- type JWT
- type NotBeforeValidationProvider
- type SignatureProvider
- type TokenIDValidationProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSignatureProvider ¶
func AddSignatureProvider(name string, provider SignatureProvider) error
AddSignatureProvider tries to add the signature provider to the list but fails when one with the same name already exists.
func AddValidationProvider ¶
func AddValidationProvider(name string, provider ContentValidationProvider) error
AddValidationProvider adds a content validation provider
func RemoveSignatureProvider ¶
func RemoveSignatureProvider(name string)
RemoveSignatureProvider removes a signature provider by name
func RemoveValidationProvider ¶
func RemoveValidationProvider(name string)
RemoveValidationProvider removes a content validation provider by name
func SetSignatureProvider ¶
func SetSignatureProvider(name string, provider SignatureProvider)
SetSignatureProvider sets the signature provider ignoring previous settings for the same name.
func SetSigningAlgorithm ¶
SetSigningAlgorithm sets the default algorithm that will be used with Encode and by the Marshalers for encoding
Types ¶
type AudienceValidationProvider ¶
type AudienceValidationProvider struct {
ExpectedAudience string
}
AudienceValidationProvider checks whether the token is for the correct audience. It should be initialized with an expected audience and will return an error when a different audience is encountered.
func (AudienceValidationProvider) Validate ¶
func (p AudienceValidationProvider) Validate(c []byte) error
Validate will be called during validation of a token
type ContentValidationProvider ¶
ContentValidationProvider is an interface for verification providers used to validate the content of a JWT
type ExpiresValidationProvider ¶
type ExpiresValidationProvider struct {
Tolerance int64
}
ExpiresValidationProvider can be used to validate that the token is currently valid. It can be initialized with a tolerance that can compensate for slight differences in clocks.
func (ExpiresValidationProvider) Validate ¶
func (p ExpiresValidationProvider) Validate(c []byte) error
Validate will be called during validation of a token
type Header ¶
type Header struct { Typ string `json:"typ"` Alg string `json:"alg"` Kid string `json:"kid,omitempty"` Jku string `json:"jku,omitempty"` Crv string `json:"crv,omitempty"` }
Header contains the header data of a JSON web token
type IssuedAtValidationProvider ¶
IssuedAtValidationProvider can be used that the token has been issued in a specific timeframe. It should be initialized with an amount of seconds after which tokens expire and optionally also a tolerance. Important: This provider also checks whether issued at timestamp is in the future and returns an error in that case.
func (IssuedAtValidationProvider) Validate ¶
func (p IssuedAtValidationProvider) Validate(c []byte) error
Validate will be called during validation of a token
type IssuerValidationProvider ¶
IssuerValidationProvider validates the issuer of a JWT. It should be initialized with a slice of issuers. By default it considers the slice a blacklist. This can be changed by setting whilelist to true.
func (IssuerValidationProvider) Validate ¶
func (p IssuerValidationProvider) Validate(c []byte) error
Validate will be called during validation of a token
type JWT ¶
JWT contains the decoded header and encoded content of a JSON web token
func Decode ¶
Decode decodes a JWT and check it's validity (use Validate() on JWT to see if it is valid)
func (JWT) MarshalBinary ¶
MarshalBinary provides encoding.BinaryMarshaler
func (JWT) MarshalText ¶
MarshalText provides encoding.TextMarshaler
func (*JWT) UnmarshalBinary ¶
UnmarshalBinary provides encoding.BinaryUnmarshaler
func (*JWT) UnmarshalText ¶
UnmarshalText provides encoding.TextUnmarshaler
func (JWT) ValidationError ¶
ValidationError returns the error that occurred during validation or nil
type NotBeforeValidationProvider ¶
type NotBeforeValidationProvider struct {
Tolerance int64
}
NotBeforeValidationProvider can be used to validate that the token is currently valid. It can be initialized with a tolerance that can compensate for slight differences in clocks.
func (NotBeforeValidationProvider) Validate ¶
func (p NotBeforeValidationProvider) Validate(c []byte) error
Validate will be called during validation of a token
type SignatureProvider ¶
type SignatureProvider interface { Sign([]byte) ([]byte, error) Verify([]byte, []byte, Header) error Header(*Header) }
SignatureProvider is an interface for algorithms used to sign and validate a JWS
type TokenIDValidationProvider ¶
type TokenIDValidationProvider struct {
ForbiddenTokenIDs []string
}
TokenIDValidationProvider can be used to blacklist some tokens. It should be initialized with a slice of forbidden token IDs and will return an error when one of those IDs in encountered.
func (TokenIDValidationProvider) Validate ¶
func (p TokenIDValidationProvider) Validate(c []byte) error
Validate will be called during validation of a token