A production-ready authentication service template built with Go, featuring user registration, login, and session management. This template uses Docker for containerization and follows modern security practices.
- User registration and login
- JWT-based authentication
- Password hashing with bcrypt
- Email verification
- Docker containerization
- RESTful API endpoints
- Rate limiting by IP
- Input validation
- Go 1.21+
- PostgreSQL
- Docker & Docker Compose
- JWT for token management
- Go-Fiber Web Framework
- Docker and Docker Compose installed
- Go 1.21 or higher (for local development)
- Make (optional, for using Makefile commands)
- Clone the repository:
git clone https://github.com/palSagnik/hermes
cd go-auth-template
- Set up environment variables:
cp .env.example .env
# Edit .env with your configurations
- Start the services using Docker Compose:
docker-compose up -d
The service will be available at http://localhost:9000
POST /auth/signup
POST /auth/login
GET /auth/verify/{token}
GET /alive
GET /api/users
GET /api/userdetails
export POSTGRES_USER="postgres"
export POSTGRES_PASSWORD="password"
export POSTGRES_HOST="postgres-db"
export POSTGRES_DATABASE="hermes"
export POSTGRES_SSLMODE="disable"
export APP_PORT="9000"
export PUBLIC_URL="localhost:9000"
export EMAIL_ID="[email protected]"
export EMAIL_AUTH="API TOKEN"
export TOKEN_SECRET="SECRET"
hermes/
├── Dockerfile
├── README.md
├── backend
│ ├── config
│ │ ├── db.go
│ │ ├── general.go
│ │ └── mailsecrets.go
│ ├── database
│ │ ├── database.go
│ │ ├── pgdata
│ │ │ └── global
│ │ ├── queries.go
│ │ └── schemas.go
│ ├── go.mod
│ ├── go.sum
│ ├── handler
│ │ ├── api.go
│ │ ├── auth.go
│ │ └── misc.go
│ ├── main.go
│ ├── middleware
│ │ ├── middleware.go
│ │ └── ratelimiter.go
│ ├── models
│ │ └── authModels.go
│ ├── router
│ │ └── routes.go
│ ├── template
│ │ └── mail.html
│ └── utils
│ ├── mail.go
│ └── utils.go
├── compose.yml
└── scripts
├── init.sh
├── reset.sh
└── run.sh
# Install dependencies
go mod download
# Run the server
# Uncomment POSTGRES_HOST = localhost
./scripts/run.sh
# Run with Docker Compose
docker compose up -d
# View logs
docker compose logs -f
- Passwords are hashed using bcrypt
- JWT tokens for authentication
- Rate limiting on authentication endpoints
- Input validation and sanitization
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.