api

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailSender

type EmailSender interface {
	Send(ctx context.Context, recipient, subject, body string) error
}

EmailSender is the minimal contract used by the activation flow. It mirrors service.EmailSender but is re-declared here so this package does not import its parent.

type Handlers

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

Handlers provides HTTP handlers for user authentication endpoints.

func NewHandlers

func NewHandlers(opts Options) *Handlers

NewHandlers returns a new Handlers instance with the given options. When opts.TokenTTL is zero the package default (30 days) is used.

func (*Handlers) ActivateEmail

func (s *Handlers) ActivateEmail(w http.ResponseWriter, r *http.Request)

ActivateEmail completes the activation flow. After a successful activation the user is logged in via the response JWT so the client can transition straight into the authenticated experience.

func (*Handlers) CreateToken

func (s *Handlers) CreateToken(w http.ResponseWriter, r *http.Request)

CreateToken handles token creation requests.

func (*Handlers) Mount

func (s *Handlers) Mount(r platform.Router)

Mount registers the user API routes on the given router.

func (*Handlers) PasskeyLoginBegin

func (s *Handlers) PasskeyLoginBegin(w http.ResponseWriter, r *http.Request)

PasskeyLoginBegin starts passkey login.

func (*Handlers) PasskeyLoginFinish

func (s *Handlers) PasskeyLoginFinish(w http.ResponseWriter, r *http.Request)

PasskeyLoginFinish completes passkey login.

func (*Handlers) PasskeyRegisterBegin

func (s *Handlers) PasskeyRegisterBegin(w http.ResponseWriter, r *http.Request)

PasskeyRegisterBegin starts passkey registration.

func (*Handlers) PasskeyRegisterFinish

func (s *Handlers) PasskeyRegisterFinish(w http.ResponseWriter, r *http.Request)

PasskeyRegisterFinish completes passkey registration.

func (*Handlers) RefreshToken

func (s *Handlers) RefreshToken(w http.ResponseWriter, r *http.Request)

RefreshToken handles token refresh requests.

func (*Handlers) Register

func (s *Handlers) Register(w http.ResponseWriter, r *http.Request)

Register handles user registration requests.

func (*Handlers) ResendActivation

func (s *Handlers) ResendActivation(w http.ResponseWriter, r *http.Request)

ResendActivation re-issues an activation token and re-sends the email. Returns 204 on success regardless of whether the email actually exists, to avoid leaking account presence; logs and internal errors are still surfaced via 5xx.

func (*Handlers) RevokeToken

func (s *Handlers) RevokeToken(w http.ResponseWriter, r *http.Request)

RevokeToken handles token revocation requests.

type Options

type Options struct {
	SigningKey     string
	TokenTTL       time.Duration
	UserStorage    *storage.UserStorage
	SessionStorage *storage.SessionStorage
	RevokedStorage *storage.RevokedTokenStorage
	PasskeyService *passkey.Service

	// Activation configuration; see service.Options.
	EmailActivationEnabled bool
	EmailSender            EmailSender
	ActivationURLFormat    string
	ActivationSubject      string
}

Options is passed from user service scope.

type RequestError

type RequestError struct {
	StatusCode int

	Err error
}

RequestError represents an HTTP error with a status code.

func (*RequestError) Error

func (r *RequestError) Error() string

Error returns the underlying error message.

Jump to

Keyboard shortcuts

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