jwt

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

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.StandardClaims

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