jwt

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// signer is an interface for an opaque private key
	// that can be used for signing operations
	Signer crypto.Signer

	// Kid is the id of the key used for signing
	Kid string
}

Config is the configuration for the JWTCA

type DefaultJWTValidator

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

func NewDefaultJWTValidator

func NewDefaultJWTValidator(c *ValidatorConfig) *DefaultJWTValidator

func (*DefaultJWTValidator) ValidateToken

func (v *DefaultJWTValidator) ValidateToken(ctx context.Context, token string) (*jwt.RegisteredClaims, error)

type Issuer

type Issuer interface {
	// IssueJWT issues a JWT and returns the JWT.
	IssueJWT(context.Context, *JWTParams) (string, error)
}

Issuer is the interface used to sign JWTs.

type JWTCA

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

JWTCA is an implementation of the Issuer interface that issues JWTs.

func NewJWTCA

func NewJWTCA(c *Config) (*JWTCA, error)

NewJWTCA creates a new JWTCA.

func (*JWTCA) IssueJWT

func (ca *JWTCA) IssueJWT(ctx context.Context, params *JWTParams) (string, error)

type JWTParams

type JWTParams struct {
	Issuer   string
	Subject  spiffeid.TrustDomain
	Audience []string
	TTL      time.Duration
}

JWTParams holds the parameters for issuing a JWT.

type Validator

type Validator interface {
	// ValidateToken ValidateJWT validates a JWT and returns the claims.
	ValidateToken(context.Context, string) (*jwt.RegisteredClaims, error)
}

Validator validates JWT tokens using a public key.

type ValidatorConfig

type ValidatorConfig struct {
	// KeyManager is the key manager used to get the public key for validating the JWT.
	KeyManager       keymanager.KeyManager
	ExpectedAudience []string
}

Jump to

Keyboard shortcuts

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