authenticationtest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package authenticationtest provides a test-double authenticator that skips real IAM: it decodes the actor from the bearer token and resolves the user through a caller-supplied lookup, so the double carries no persistence dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator[U any] struct {
	// contains filtered or unexported fields
}

Authenticator decodes the bearer token as a base64-encoded JSON Actor and resolves the user via lookup. The lookup owns persistence concerns (querying, not-found mapping), keeping this double free of any storage dependency.

func New

func New[U any](lookup func(ctx context.Context, id uuid.UUID) (*U, error)) *Authenticator[U]

func (*Authenticator[U]) Authenticate

func (a *Authenticator[U]) Authenticate(ctx context.Context, token string) (*authorization.Actor, *U, error)

func (*Authenticator[U]) EnsureRoles

func (a *Authenticator[U]) EnsureRoles(
	_ context.Context, _ string, actor *authorization.Actor,
) (*authorization.Actor, error)

EnsureRoles is a no-op: the token already encodes the full actor, including its permissions and admin flag.

Jump to

Keyboard shortcuts

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