Overview
Snare is an authentication module for Gin applications. It wires login, registration, logout, and auth-state routes with cookie-backed sessions and SQLite-backed user storage.
What It Provides
- Session-based authentication with
gin-contrib/sessions - HTML auth pages (
/auth/*) rendered with Templ - API auth endpoints (
/api/auth/*) - Route protection middleware for authenticated-only handlers
- Password hashing with bcrypt
Storage Model
- User data is persisted in SQLite
- Session state is managed via cookie store middleware
Route Groups
- HTML pages for login/register/logout
- API handlers for login/register/logout/state
Use Snare when you want server-rendered auth plus API endpoints without rebuilding auth plumbing from scratch.