token

package
v0.0.0-...-2c51af3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("authentication/token: invalid token")
)

Functions

func New

func New[T any](storage Storage[T], issuer Issuer[T]) strategy.Authenticator[T]

New returns a new authenticator that authenticates using a bearer token.

Types

type Issuer

type Issuer[T any] interface {
	Issue(ctx context.Context, user *strategy.User[T]) (*Token, error)
}

type Storage

type Storage[T any] interface {
	Retrieve(context.Context, Token) (*strategy.Session[T], error)
}

type Token

type Token struct {
	// AccessToken is a token allowing to access the protected resource.
	//
	// It can be any kind of bearer token, i.e., a JWT, an opaque token, etc.
	AccessToken string

	// RefreshToken is a typically used to refresh the access token.
	//
	// If can be an empty string when there is no need to refresh a token.
	RefreshToken string
}

Token cares information about an access token.

Jump to

Keyboard shortcuts

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