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

onetimeaccess

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0, MIT Imports: 21 Imported by: 0

Documentation

Overview

Package onetimeaccess issues single-use sign-in tokens delivered by email: admins mint them per user; unauthenticated users may request one for their own address when the app policy allows. Storage: auth_tokens (purpose = one_time_access, hash at rest) via the shared token store.

Index

Constants

View Source
const (
	// TokenTTL bounds one-time access tokens.
	TokenTTL = 15 * time.Minute
	// ResendThrottle bounds re-request frequency.
	ResendThrottle = time.Minute
)

Token lifetime and resend throttle.

Variables

View Source
var (
	// ErrNotFound covers unknown tokens/users without leaking which.
	ErrNotFound = errors.New("onetimeaccess: token is invalid or expired")
	// ErrThrottled rejects re-requests inside the resend window.
	ErrThrottled = errors.New("onetimeaccess: request throttled")
)

Errors surfaced to handlers.

Functions

This section is empty.

Types

type Feature

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

Feature is the wireable unit.

func New

func New(service *Service) Feature

New wires the feature to its service.

func (Feature) APIRoutes

func (f Feature) APIRoutes(r chi.Router, _ identity.RouteGroups)

APIRoutes mounts the retained one-time access endpoints relative to the /api group: only the email-link token exchange. The email request and the admin surface serve ConnectRPC below /rpc.

func (Feature) Name

func (Feature) Name() string

Name names the feature for logs.

func (Feature) RPCService added in v0.0.12

func (f Feature) RPCService() (string, http.Handler)

RPCService returns the Connect registration for the one-time access surface.

func (Feature) WithAccessAuthenticator added in v0.0.12

func (f Feature) WithAccessAuthenticator(access kernel.AccessAuthenticator) Feature

WithAccessAuthenticator wires the bearer resolver the admin procedures guard with.

type Service

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

Service orchestrates one-time access tokens.

func NewService

func NewService(store token.Store, users user.Store, sessions *session.Service, recorder identity.Recorder, opts ...ServiceOption) *Service

NewService builds the feature.

func (*Service) Name

func (s *Service) Name() string

Name names the feature for logs.

func (*Service) RPCService added in v0.0.12

func (s *Service) RPCService(access kernel.AccessAuthenticator) (string, http.Handler)

RPCService returns the Connect registration for the one-time access surface. RequestEmail is anonymous (enumeration-safe 204); the admin procedures resolve the bearer and demand an admin. The token exchange itself stays the REST email-link endpoint.

type ServiceOption

type ServiceOption func(*Service)

ServiceOption configures the feature.

func WithMail

func WithMail(sender identity.MailSender, appURL string) ServiceOption

WithMail wires the queued email sender and the base URL used to build the sign-in link.

Jump to

Keyboard shortcuts

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