login

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: LGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package login holds the demo examples for login flows: handlers that verify credentials and establish a session (password form, passwordless email code, password+TOTP, recovery code), as opposed to authentication methods that authenticate each request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func API

func API(log *slog.Logger, users *user.Service, pw *password.Service, mfaSvc mfa.Services) *loginhandlers.JSON

API exposes password+TOTP login as a JSON API using the login/handlers preset — the transport SPAs would consume. Password-only users complete at the login endpoint; users with TOTP enrolled (e.g. via /profile) get {"done":false,"next":["totp","recovery"]} and complete at the verify endpoint. The demo mounts LoginHandler and VerifyHandler on the router.

func Email

func Email(log *slog.Logger, users userauth.UserGetter, rnd *web.Renderer) http.Handler

Email demonstrates passwordless email-code login persisted in a cookie session, built on loginflow with a single-factor email policy. The demo supplies a Deliverer that shows the code on the verify page instead of emailing it.

func Password

func Password(log *slog.Logger, users userauth.UserGetter, rnd *web.Renderer) http.Handler

Password demonstrates username+password form login persisted in a cookie session, built on loginflow with a single-factor password policy. The flow keeps all credential failures (unknown user, disabled user, wrong password) indistinguishable; the demo owns the form parsing and rendering.

func Recovery

func Recovery(log *slog.Logger, rnd *web.Renderer) http.Handler

Recovery demonstrates completing a two-factor login with a single-use recovery code instead of the authenticator: the scenario where the user has lost their device. The policy requires the password first and a recovery code second; each code is consumed on use.

func Section

func Section(log *slog.Logger, users *user.Service, pw *password.Service, mfaSvc mfa.Services, rnd *web.Renderer) examples.Section

Section describes the login-flow examples for the demo index and mounts them on the router. The form examples need only the read side of users; the JSON API additionally verifies passwords.

func TOTP

func TOTP(log *slog.Logger, rnd *web.Renderer) http.Handler

TOTP demonstrates a two-step login: the policy requires the password first and an authenticator code second, on every login. The verify page shows the currently valid code (simulating the user's authenticator app).

Types

This section is empty.

Jump to

Keyboard shortcuts

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