jwt

package
v2.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ClaimExpiresAt = "exp"
	ClaimScope     = "scope"
	ClaimAudience  = "aud"
	ClaimID        = "jti"
	ClaimIssuer    = "iss"
	ClaimSubject   = "sub"
	ClaimIssuedAt  = "iat"
	ClaimNotBefore = "nbf"
	ClaimClientID  = "client_id"
	ClaimEmail     = "email"
	ClaimName      = "n"
)
View Source
const PlgdRequiredScope = "plgd:required:scope"

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims jwt.MapClaims

func ParseToken

func ParseToken(token string) (Claims, error)

func (Claims) Audience

func (c Claims) Audience() []string

func (Claims) ClientID

func (c Claims) ClientID() string

func (Claims) DeviceID

func (c Claims) DeviceID(deviceIDClaim string) string

func (Claims) Email

func (c Claims) Email() string

func (Claims) ExpiresAt

func (c Claims) ExpiresAt() (time.Time, error)

Get expiration time (exp) from user info map. It might not be set, in that case zero time and no error are returned.

func (Claims) ID

func (c Claims) ID() string

func (Claims) IssuedAt

func (c Claims) IssuedAt() (time.Time, error)

func (Claims) Issuer

func (c Claims) Issuer() string

func (Claims) Name

func (c Claims) Name() string

func (Claims) NotBefore

func (c Claims) NotBefore() (time.Time, error)

func (Claims) Owner

func (c Claims) Owner(ownerClaim string) string

func (Claims) Scope

func (c Claims) Scope() []string

func (Claims) Subject

func (c Claims) Subject() string

func (Claims) Valid

func (c Claims) Valid() error

func (Claims) ValidTimes

func (c Claims) ValidTimes(now time.Time) error

func (Claims) ValidateOwnerClaim

func (c Claims) ValidateOwnerClaim(ownerClaim string, userID string) error

Validate that ownerClaim is set and that it matches given user ID

type KeyCache

type KeyCache struct {
	// contains filtered or unexported fields
}

func NewKeyCache

func NewKeyCache(url string, client *http.Client) *KeyCache

func (*KeyCache) FetchKeys

func (c *KeyCache) FetchKeys() error

func (*KeyCache) FetchKeysWithContext

func (c *KeyCache) FetchKeysWithContext(ctx context.Context) error

func (*KeyCache) GetKey

func (c *KeyCache) GetKey(token *jwt.Token) (interface{}, error)

func (*KeyCache) GetOrFetchKey

func (c *KeyCache) GetOrFetchKey(token *jwt.Token) (interface{}, error)

func (*KeyCache) GetOrFetchKeyWithContext

func (c *KeyCache) GetOrFetchKeyWithContext(ctx context.Context, token *jwt.Token) (interface{}, error)

func (*KeyCache) LookupKey

func (c *KeyCache) LookupKey(token *jwt.Token) (jwk.Key, error)

type ScopeClaims

type ScopeClaims Claims

func NewRegexpScopeClaims

func NewRegexpScopeClaims(scope ...*regexp.Regexp) *ScopeClaims

func NewScopeClaims

func NewScopeClaims(scope ...string) *ScopeClaims

func (*ScopeClaims) Valid

func (c *ScopeClaims) Valid() error

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator(keyCache *KeyCache) *Validator

func (*Validator) Parse

func (v *Validator) Parse(token string) (jwt.MapClaims, error)

func (*Validator) ParseWithClaims

func (v *Validator) ParseWithClaims(token string, claims jwt.Claims) error

func (*Validator) ParseWithContext

func (v *Validator) ParseWithContext(ctx context.Context, token string) (jwt.MapClaims, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL