No description
Find a file
2025-09-20 16:08:24 +02:00
cmd/server docs: add readme and make tooling targets 2025-09-20 15:41:35 +02:00
internal feat: unify auth templates 2025-09-20 16:08:24 +02:00
web feat: unify auth templates 2025-09-20 16:08:24 +02:00
.air.toml refactor: modularize server routes 2025-09-19 23:46:40 +02:00
.gitignore feat: initialize Go project with basic setup 2025-08-01 16:31:29 +02:00
AGENTS.md docs: add readme and make tooling targets 2025-09-20 15:41:35 +02:00
AUTH_PLAN.md refactor: adopt slog for structured logging 2025-09-20 14:13:54 +02:00
go.mod docs: add readme and make tooling targets 2025-09-20 15:41:35 +02:00
go.sum refactor: modularize server routes 2025-09-19 23:46:40 +02:00
Makefile docs: add readme and make tooling targets 2025-09-20 15:41:35 +02:00
README.md docs: add readme and make tooling targets 2025-09-20 15:41:35 +02:00

Auth Demo

Auth Demo showcases a fully server-rendered email/password authentication flow with secure session management, CSRF protection, structured logging, and embedded templates/assets for single-binary deployment.

Capabilities

  • Email/password signup and login backed by salted hashing and reusable auth services.
  • CSRF-protected session middleware with signed cookies and automatic token rotation.
  • Structured logging (text or JSON) and environment-driven configuration for production parity.
  • Embedded templates styled with Pico.css and progressively enhanced with htmx and Alpine.js.

Getting Started

  1. Review or adjust the defaults in .env. To load them in POSIX shells, run set -a; . ./.env; set +a.

  2. Use the targets in the Makefile:

    Target Description
    make run Start the HTTP server with the current environment.
    make dev Launch Air for live reload (requires air on PATH).
    make build Compile to ./bin/auth-server.
    make test Run go test ./... -cover -count=1.
  3. Visit the login page (default http://localhost:8000) and authenticate with the demo credentials displayed on screen.

Configuration

Settings are sourced from environment variables (see .env).

Variable Required Default Description
AUTH_SESSION_SECRET Yes Base64-encoded secret used to sign session cookies.
AUTH_LISTEN_ADDR No :8000 Address the HTTP server binds to.
AUTH_ENV No development Environment label, controls logger source annotation.
AUTH_LOG_MODE No text Structured log encoder (text or json).

Project Layout

  • cmd/server — application entrypoint.
  • internal/config — environment-backed configuration loader.
  • internal/driver/loggingslog helpers for text/JSON output.
  • internal/service/auth — authentication domain logic, hashing, validation.
  • internal/server — router, middleware, handlers, session store.
  • web/templates — embedded HTML templates.

Built With

  • Go — standard library HTTP, templates, crypto, and embed.
  • Chi — lightweight router and middleware stack.
  • htmx — progressive enhancement via HTML attributes.
  • Alpine.js — declarative client-side interactions.
  • Pico.css — minimal, semantic-first styling.

License

MIT