A secure authentication system built with Go, JWT, and SQLite. This application provides a complete authentication solution with user registration, login, and protected routes.
git clone https://github.com/Andy6309/Go-Auth.git
cd Go-Auth
go mod download
cp .env.example .env
Edit the .env
file with your configuration.
Create a .env
file in the project root:
PORT=3010
JWT_SECRET=your_secure_secret_here
JWT_EXPIRATION=24h
DB_PATH=./db-data/auth.db
mkdir -p db-data
go run cmd/server/main.go
http://localhost:3010
POST /api/auth/register
{ "username": "user", "password": "password" }
POST /api/auth/login
{ "username": "user", "password": "password" }
{ "token": "jwt.token.here", "expires_in": 86400, "token_type": "Bearer" }
GET /api/profile
Authorization: Bearer <token>
headerGo-Auth/
├── cmd/
│ └── server/
│ └── main.go # Application entry point
├── internal/
│ ├── auth/ # Authentication logic
│ ├── config/ # Configuration management
│ ├── handlers/ # HTTP request handlers
│ ├── middleware/ # HTTP middleware
│ └── models/ # Data models and database operations
├── static/ # Frontend files
│ └── index.html
├── .env.example # Example environment variables
├── go.mod # Go module definition
└── README.md # This file
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.