security

package
v1.51.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const SecretKeySize = 32

SecretKeySize is the required decoded length of an Authula secret. It matches the XChaCha20-Poly1305 key size used for token encryption.

Variables

View Source
var ErrInvalidSecret = errors.New("invalid secret")

ErrInvalidSecret indicates that a secret is empty, contains whitespace, is not standard padded Base64, or does not decode to exactly SecretKeySize bytes.

Functions

func DecodeSecret added in v1.51.0

func DecodeSecret(value string) ([]byte, error)

DecodeSecret decodes a standard padded Base64 secret.

Types

type HMACSigner

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

func NewHMACSigner

func NewHMACSigner(secret []byte) *HMACSigner

NewHMACSigner creates a signer from an already-decoded 32-byte key.

func (*HMACSigner) Generate

func (s *HMACSigner) Generate(ctx context.Context, subject string) (string, error)

Generate creates a cryptographically signed token.

func (*HMACSigner) Verify

func (s *HMACSigner) Verify(ctx context.Context, token string, payload []byte) (bool, error)

Verify verifies a token signature against a payload.

type TokenSigner

type TokenSigner interface {
	Generate(ctx context.Context, subject string) (string, error)
	Verify(ctx context.Context, token string, payload []byte) (bool, error)
}

TokenSigner signs and verifies cryptographically secure tokens.

Jump to

Keyboard shortcuts

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