auth

package
v0.0.0-...-e7c744b Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoExpiration time.Time //nolint:gochecknoglobals

NoExpiration can be passed to the generator to indicate no expiration time.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	// Now tells the current time.
	Now() time.Time
}

Clock provides an interface to Time.

type IDGenerator

type IDGenerator interface {
	Generate() string
}

IDGenerator generates an opaque ID.

type JWTTokenGenerator

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

JWTTokenGenerator generates an API token.

func NewJWTTokenGenerator

func NewJWTTokenGenerator(issuer string, audience string, signingKey string, opts ...JWTTokenGeneratorOption) JWTTokenGenerator

NewJWTTokenGenerator returns a new JWTTokenGenerator.

func (JWTTokenGenerator) GenerateToken

func (g JWTTokenGenerator) GenerateToken(sub string, expiresAt time.Time, tokenType string, tokenText string) (string, string, error)

GenerateToken generates a JWT token.

type JWTTokenGeneratorOption

type JWTTokenGeneratorOption interface {
	// contains filtered or unexported methods
}

JWTTokenGeneratorOption option configures optional parameters of a JWTTokenGenerator.

func TokenGeneratorClock

func TokenGeneratorClock(clock Clock) JWTTokenGeneratorOption

TokenGeneratorClock sets the clock in a JWTTokenGenerator. It falls back to the system clock.

func TokenIDGenerator

func TokenIDGenerator(idgen IDGenerator) JWTTokenGeneratorOption

TokenIDGenerator sets the ID Generator in a JWTTokenGenerator. It falls back to UUID.

func TokenSigningMethod

func TokenSigningMethod(signingMethod jose.SignatureAlgorithm) JWTTokenGeneratorOption

TokenSigningMethod sets the signing method in a JWTTokenGenerator. It falls back to HS256.

type TokenGenerator

type TokenGenerator interface {
	// GenerateToken generates a token.
	GenerateToken(sub string, expiresAt time.Time, tokenType string, tokenText string) (string, string, error)
}

TokenGenerator generates a token.

type TokenManager

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

TokenManager manages tokens.

func NewTokenManager

func NewTokenManager(generator TokenGenerator, store auth.TokenStore) TokenManager

NewTokenManager returns a new TokenManager.

func (TokenManager) GenerateToken

func (m TokenManager) GenerateToken(
	sub string,
	expiresAt time.Time,
	tokenType TokenType,
	tokenText string,
	tokenName string,
	storeSecret bool,
) (tokenID string, signedToken string, err error)

GenerateToken generates a token and stores it in the token store.

type TokenType

type TokenType string

TokenType represents one of the possible token Types.

Jump to

Keyboard shortcuts

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