token

package
v0.1.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ClientIDCookie = "CLIENTID"

ClientIDCookie is the cookie name used to set the token's ClientID value on a client.

Variables

This section is empty.

Functions

func NewService

func NewService(options ...ConfigOption) auth.TokenService

NewService returns a new TokenService.

Types

type ConfigOption

type ConfigOption func(*service)

ConfigOption configures the service.

func WithCookieDomain

func WithCookieDomain(domain string) ConfigOption

WithCookieDomain configures the service with the domain for a secure cookie.

func WithCookieMaxAge

func WithCookieMaxAge(age int) ConfigOption

WithCookieMaxAge sets the max age for an HTTP cookie. Defaults to 7 days.

func WithDB

func WithDB(db Rediser) ConfigOption

WithDB configures the service with a redis DB

func WithEntropy

func WithEntropy(entropy io.Reader) ConfigOption

WithEntropy configures the client with random entropy for generating ULIDs.

func WithIssuer

func WithIssuer(issuer string) ConfigOption

WithIssuer is the issuer identity for the JWT token.

func WithLogger

func WithLogger(l log.Logger) ConfigOption

WithLogger configures the service with a logger.

func WithOTP

func WithOTP(o auth.OTPService) ConfigOption

WithOTP configures the service with an OTP management service.

func WithSecret

func WithSecret(secret string) ConfigOption

WithSecret configures the service with a secret value for signing functions.

func WithTokenExpiry

func WithTokenExpiry(expiresIn time.Duration) ConfigOption

WithTokenExpiry defines how long tokens are valid for. The default value is 20 minutes.

type Rediser

type Rediser interface {
	Get(key string) *redislib.StringCmd
	Set(key string, value interface{}, expiration time.Duration) *redislib.StatusCmd
	WithContext(ctx context.Context) *redislib.Client
	Close() error
}

Rediser is an interface to go-redis.

Jump to

Keyboard shortcuts

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