Help us shape the future of Go! Take the 2026 Go Developer Survey

authn

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWT

func GenerateJWT(clientName string, roles []string, duration time.Duration) (string, error)

GenerateJWT creates a signed JWT with roles and specified expiry duration

func GenerateRandomToken

func GenerateRandomToken() (string, error)

GenerateRandomToken returns a secure 32-byte (256-bit) random token as hex string

func GetClientName

func GetClientName(ctx context.Context) string

func GetClientRoles

func GetClientRoles(ctx context.Context) []string

func LoadJWTConfig

func LoadJWTConfig(cfg JWTConfig)

func ValidateJWT

func ValidateJWT(tokenStr string) (*jwt.Token, jwt.MapClaims, error)

func WithClientMetadata

func WithClientMetadata(ctx context.Context, name string, roles []string) context.Context

Types

type JWTConfig

type JWTConfig struct {
	Secret   []byte
	Issuer   string
	Audience string
}

Load the JWT env

Jump to

Keyboard shortcuts

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