http

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

func Mount(mux webx.Router, d Deps)

func MountFedAdmin

func MountFedAdmin(mux webx.Router, d Deps)

func MountMFA added in v0.5.0

func MountMFA(mux webx.Router, d Deps)

MountMFA registers the MFA routes. MFAChangeGuard (when set) wraps the settings-mutating routes — a product policy guard such as webx.RequireRecentAuth(15 * time.Minute).

func Routes

func Routes(d Deps) http.Handler

Types

type Deps

type Deps struct {
	AuthCfg     webx.AuthConfig
	Sessions    webx.SessionStore
	PATs        webx.PATLookup
	SessionsSvc *app.SessionService
	Tokens      *app.TokenService

	Account *app.AccountService

	OAuth *app.OAuthService

	Fed *app.FedService

	FedAdminGuard func(http.Handler) http.Handler

	// MFA, when non-nil, mounts the TOTP flows (ADR 0013 batch 2):
	// /auth/mfa/* + POST /auth/verify-mfa. Nil = the capability is absent,
	// not degraded — MFA cannot half-exist.
	MFA *app.MFAService

	// MFAChangeGuard wraps the MFA settings-mutating routes (disable /
	// regenerate-backup-codes) in the product's step-up policy — e.g.
	// webx.RequireRecentAuth(15 * time.Minute), mirroring GitHub's
	// sudo-guarded 2FA settings. The window is product policy (no package
	// default). Nil = no guard (dev convenience; production should set it).
	MFAChangeGuard func(http.Handler) http.Handler

	// PATCreateGuard, when non-nil, wraps POST /api/tokens — the product's
	// gate for PAT creation (GitHub guards token generation behind sudo /
	// AAL2 step-up; the strong-profile road mounts its catalog middleware
	// here, the simple road webx.RequireRecentAuth / RequireRecentMFA).
	// Nil = creation needs only a human session.
	PATCreateGuard func(http.Handler) http.Handler

	// BotGuard, when non-nil, wraps the bot-facing auth routes (register /
	// send-code / forgot-password / send-verification) in the product's
	// human verification — e.g. webx.Turnstile (Cloudflare). On
	// send-verification it sits OUTSIDE RequireHuman: a bot must be judged
	// before it can elicit a session-verdict. login / verify-code /
	// reset-password stay unguarded (per-IP rate limiting is their defense;
	// adding the guard there is product policy, one line away). Nil = the
	// capability is absent, behavior unchanged.
	BotGuard func(http.Handler) http.Handler

	// OAuthAppURL is where OAuth success/failure 302s land (the product's
	// public origin). When OAuth is wired and this still points at loopback,
	// Mount logs a warning — the shuijing 2026-10-31 deployment enabled
	// Google login in production without setting it, sending successful
	// logins to a dead localhost:5173 (the dev default had never been
	// exercised because OAuth had never been enabled before).
	OAuthAppURL string

	TrustedProxies []*net.IPNet
}

Jump to

Keyboard shortcuts

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