How sven-seyfert/secure-web-auth-template works
Secure Web Auth Template is a compact browser-based authentication app. A user interacts with the web UI to register, log in, use a session-and-CSRF-protected action, and log out. The Go API owns those request flows: it validates credentials, hashes passwords, issues cookies, checks authorization, and updates SQLite-backed user/session records. The application entry point initializes storage, serves the UI and routes, and applies security headers. The README documents capabilities beyond the sampled implementation; those relationships are shown only where documented, and unsampled internals are not inferred.
Main entry points: routes.go Login flow · db.go User and session storage · main.go HTTP server entry · index.html Auth UI
Components 17
Browser interface
- Auth UI
web/index.html - Form and cookie logic
web/js/main.js
HTTP application
- HTTP server entry
main.go - API routes and handlers
internal/api/routes.go - Security headers
internal/api/routes.go
Identity and sessions
- Registration flow
internal/api/routes.go - Login flow
internal/api/routes.go - Protected action
internal/api/routes.go - Logout flow
internal/api/routes.go - Session and CSRF checks
internal/auth/authorize.go - Token and cookie handling
internal/auth/session.go - Credential validation
internal/utils/utils.go - Password hashing
internal/utils/utils.go - Random token generation
internal/utils/utils.go
User persistence
- User and session storage
internal/storage/db.go - SQLite
Other components
- Browser user
Connections 27
- Browser user → Auth UI: uses
README.md - Auth UI → Form and cookie logic: loads
- Form and cookie logic → API routes and handlers: submits requests
web/js/main.js - HTTP server entry → API routes and handlers: registers routes
main.go - HTTP server entry → User and session storage: initializes
main.go - HTTP server entry → Auth UI: serves assets
main.go - HTTP server entry → Security headers: wraps handler
main.go - API routes and handlers → Security headers: applies headers
internal/api/routes.go - API routes and handlers → Registration flow: routes registration
internal/api/routes.go - API routes and handlers → Login flow: routes login
internal/api/routes.go - API routes and handlers → Protected action: routes protected action
internal/api/routes.go - API routes and handlers → Logout flow: routes logout
internal/api/routes.go - Registration flow → Credential validation: validates
internal/api/routes.go - Registration flow → Password hashing: hashes password
internal/api/routes.go - Registration flow → User and session storage: creates user
internal/api/routes.go - Login flow → Credential validation: validates
internal/api/routes.go - Login flow → User and session storage: loads user
internal/api/routes.go - Login flow → Password hashing: checks hash
internal/api/routes.go - Login flow → Token and cookie handling: issues cookies
internal/api/routes.go - Login flow → Random token generation: requests tokens
- Login flow → User and session storage: stores session
internal/api/routes.go - Protected action → Session and CSRF checks: requires authorization
internal/api/routes.go - Session and CSRF checks → User and session storage: loads user
internal/auth/authorize.go - Logout flow → Session and CSRF checks: requires authorization
internal/api/routes.go - Logout flow → Token and cookie handling: clears cookies
internal/api/routes.go - Logout flow → User and session storage: clears session
internal/api/routes.go - User and session storage → SQLite: reads and writes
README.md