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 ¶
- func API(log *slog.Logger, users *user.Service, pw *password.Service, ...) *loginhandlers.JSON
- func Email(log *slog.Logger, users userauth.UserGetter, rnd *web.Renderer) http.Handler
- func Password(log *slog.Logger, users userauth.UserGetter, rnd *web.Renderer) http.Handler
- func Recovery(log *slog.Logger, rnd *web.Renderer) http.Handler
- func Section(log *slog.Logger, users *user.Service, pw *password.Service, ...) examples.Section
- func TOTP(log *slog.Logger, rnd *web.Renderer) http.Handler
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 ¶
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 ¶
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 ¶
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.
Types ¶
This section is empty.