token

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const SubjectKey = "subject"

SubjectKey for token.

Variables

Module for fx.

Functions

func IsEnabled

func IsEnabled(cfg *Config) bool

IsEnabled for token.

func Subject

func Subject(ctx context.Context) meta.Value

Subject for token.

func WithSubject

func WithSubject(ctx context.Context, id meta.Value) context.Context

WithSubject for token.

Types

type Config

type Config struct {
	JWT    *jwt.Config    `yaml:"jwt,omitempty" json:"jwt,omitempty" toml:"jwt,omitempty"`
	Paseto *paseto.Config `yaml:"paseto,omitempty" json:"paseto,omitempty" toml:"paseto,omitempty"`
	SSH    *ssh.Config    `yaml:"ssh,omitempty" json:"ssh,omitempty" toml:"ssh,omitempty"`
	Kind   string         `yaml:"kind,omitempty" json:"kind,omitempty" toml:"kind,omitempty"`
}

Config for token.

func (*Config) IsJWT

func (c *Config) IsJWT() bool

IsJWT for configuration.

func (*Config) IsPaseto

func (c *Config) IsPaseto() bool

IsPaseto for configuration.

func (*Config) IsSSH

func (c *Config) IsSSH() bool

IsSSH for configuration.

type Generator

type Generator interface {
	// Generate a new token or error.
	Generate(ctx context.Context) (context.Context, []byte, error)
}

Generator allows the implementation of different types generators.

type Params

type Params struct {
	fx.In

	Config *Config
	JWT    *jwt.Token
	Paseto *paseto.Token
	SSH    *ssh.Token
	Name   env.Name
}

Params for token.

type Token

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

Token will generate and verify based on what is defined in the config.

func NewToken

func NewToken(params Params) *Token

NewToken based on config.

func (*Token) Generate

func (t *Token) Generate(ctx context.Context) (context.Context, []byte, error)

func (*Token) Verify

func (t *Token) Verify(ctx context.Context, token []byte) (context.Context, error)

type Verifier

type Verifier interface {
	// Verify a token or error.
	Verify(ctx context.Context, token []byte) (context.Context, error)
}

Verifier allows the implementation of different types of verifiers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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