onetimeaccess

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0, MIT Imports: 14 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, g identity.RouteGroups)

APIRoutes mounts the one-time access endpoints relative to the /api group.

func (Feature) Name

func (Feature) Name() string

Name names the feature for logs.

func (Feature) WithCookie

func (f Feature) WithCookie(name string, secure bool) Feature

WithCookie wires the session cookie settings for the exchange.

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.

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