Snare is a modular authentication package for Go web applications built with the Gin framework. It provides session-based authentication with server-rendered HTML responses using the Templ component system.
- Session-based authentication using secure HTTP-only cookies
- Login, registration, and logout endpoints
- Middleware for protected routes
- SQLite storage for user data
- Password hashing with bcrypt
- Separated API and HTML views
GET /auth/login– Login pageGET /auth/register– Registration pageGET /auth/logout– Logout (requires session)
POST /api/auth/login– Authenticate userPOST /api/auth/register– Register new userGET /api/auth/logout– Invalidate sessionGET /api/auth/state– Session status (protected)
- Session data stored using
gin-contrib/sessionswith cookie backend - Passwords are hashed with bcrypt
- CSRF protection and cookie flags should be handled at the reverse proxy level
MIT License