jwt

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRandomKey

func NewRandomKey(method string) (string, error)

func ParseWithClaims

func ParseWithClaims(tokenString string, claims jwt.Claims, issuerFunc func(token *jwt.Token) (JWTIssuer, error)) (*jwt.Token, error)

Types

type Claims

type Claims interface {
	jwt.Claims
	SetIssuer(context.Context, string)
}

type JWTConfig

type JWTConfig struct {
	PrivateKey any
	PublicKey  crypto.PublicKey
	Algorithm  jwt.SigningMethod
	Issuer     string
}

func NewJWTConfig

func NewJWTConfig(issuer, method, privateKey string) (*JWTConfig, error)

func NewJWTConfigBySecret

func NewJWTConfigBySecret(secret string) (*JWTConfig, error)

func NewRandomRSAJWTConfig

func NewRandomRSAJWTConfig() (*JWTConfig, error)

func (*JWTConfig) GetPublicKey

func (j *JWTConfig) GetPublicKey() crypto.PublicKey

func (*JWTConfig) ParseWithClaims

func (j *JWTConfig) ParseWithClaims(tokenString string, claims jwt.Claims) (*jwt.Token, error)

func (*JWTConfig) SignedString

func (j *JWTConfig) SignedString(ctx context.Context, claims Claims) (string, error)

func (*JWTConfig) UnmarshalJSON

func (j *JWTConfig) UnmarshalJSON(bytes []byte) (err error)

type JWTIssuer

type JWTIssuer interface {
	SignedString(ctx context.Context, claims Claims) (string, error)
	ParseWithClaims(tokenString string, claims jwt.Claims) (*jwt.Token, error)
	GetPublicKey() crypto.PublicKey
}

func NewJWTIssuer

func NewJWTIssuer(issuerId string, method, privateKey string) (JWTIssuer, error)

type StandardClaims

type StandardClaims jwt.RegisteredClaims

func (StandardClaims) GetAudience added in v1.5.3

func (c StandardClaims) GetAudience() (jwt.ClaimStrings, error)

func (StandardClaims) GetExpirationTime added in v1.5.3

func (c StandardClaims) GetExpirationTime() (*jwt.NumericDate, error)

func (StandardClaims) GetIssuedAt added in v1.5.3

func (c StandardClaims) GetIssuedAt() (*jwt.NumericDate, error)

func (StandardClaims) GetIssuer added in v1.5.3

func (c StandardClaims) GetIssuer() (string, error)

func (StandardClaims) GetNotBefore added in v1.5.3

func (c StandardClaims) GetNotBefore() (*jwt.NumericDate, error)

func (StandardClaims) GetSubject added in v1.5.3

func (c StandardClaims) GetSubject() (string, error)

func (*StandardClaims) SetIssuer

func (c *StandardClaims) SetIssuer(ctx context.Context, issuer string)

func (StandardClaims) Valid

func (c StandardClaims) Valid() error

Jump to

Keyboard shortcuts

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