token

package
v2.78.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

Module for fx.

Functions

func IsEnabled

func IsEnabled(cfg *Config) bool

IsEnabled for token.

Types

type Config

type Config struct {
	Access *access.Config `yaml:"access,omitempty" json:"access,omitempty" toml:"access,omitempty"`
	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(aud, sub string) ([]byte, error)
}

Generator allows the implementation of different types generators.

func NewGenerator added in v2.34.0

func NewGenerator(token *Token) Generator

NewGenerator 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 TokenParams) *Token

NewToken based on config.

func (*Token) Generate

func (t *Token) Generate(aud, sub string) ([]byte, error)

Generate a token based on kind.

func (*Token) Verify

func (t *Token) Verify(token []byte, aud string) (string, error)

Verify a token based on kind.

type TokenParams added in v2.32.0

type TokenParams struct {
	di.In

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

TokenParams for token.

type Verifier

type Verifier interface {
	// Verify a token or error.
	Verify(token []byte, aud string) (string, error)
}

Verifier allows the implementation of different types of verifiers.

func NewVerifier added in v2.34.0

func NewVerifier(token *Token) Verifier

NewVerifier for token.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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