Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilKey indicates that key is nil. ErrNilKey = errors.New("key is nil") // ErrInvalidKey indicates that key is not valid. ErrInvalidKey = errors.New("key is not valid") // ErrUnsupportedAlg indicates that given algorithm is not supported. ErrUnsupportedAlg = errors.New("algorithm is not supported") // ErrInvalidSignature indicates that signature is not valid. ErrInvalidSignature = errors.New("signature is not valid") )
JWT sign, verify, build and parse errors.
var ( // ErrHeaderMissing missing header. ErrHeaderMissing = fmt.Errorf("jwt authorization header is missing") // ErrVMAccessFieldMissing missing vm_access field. ErrVMAccessFieldMissing = fmt.Errorf("missing `vm_access` claim") // ErrBadTokenFormat incorrect format for token ErrBadTokenFormat = fmt.Errorf("bad token format, must be jwt") )
var ( // ErrSignatureVerificationFailed token signature verification failed ErrSignatureVerificationFailed = fmt.Errorf("failed to verify token signature") // ErrSignatureAlgorithmNotSupported signature algorithm not supported ErrSignatureAlgorithmNotSupported = fmt.Errorf("signature algorithm verification not supported, supported algorithms: RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384, ES512") )
Functions ¶
Types ¶
type Algorithm ¶
type Algorithm string
Algorithm for signing and verifying.
type Labels ¶
Labels defines labels added to filters or incoming time series.
func (Labels) AsExtraLabels ¶
AsExtraLabels - converts labels to label=value pairs.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token represents jwt token https://auth0.com/docs/tokens/json-web-tokens
func NewTokenFromRequestWithCustomHeader ¶
func NewTokenFromRequestWithCustomHeader(r *http.Request, headerName string, enforceAuthPrefix bool) (*Token, error)
NewTokenFromRequestWithCustomHeader return new jwt token from request by provided header
func (*Token) AccessLabels ¶
AccessLabels returns access labels for given JWT token, in key=value format.
func (*Token) ExtraFilters ¶
ExtraFilters metricsql filters for select queries
type VerifierPool ¶
type VerifierPool struct {
// contains filtered or unexported fields
}
VerifierPool is a pool of verifiers for different algorithms
func NewVerifierPool ¶
func NewVerifierPool(keys []any) (*VerifierPool, error)
NewVerifierPool creates a new verifier pool for a set of keys
func (*VerifierPool) Verify ¶
func (vp *VerifierPool) Verify(token *Token) error
Verify verifies a token signature by using keys provided to verifier pool