Fiber Auth is a lightweight authentication service built with the Fiber web framework for Go.
- User registration and login
- JWT-based authentication
- Secure password hashing
- Middleware for protected routes
-
Clone the repository:
git clone https://github.com/yourusername/fiber-auth.git cd fiber-auth -
Install dependencies:
go mod tidy
-
Set up database:
- Ensure you have a PostgreSQL database running.
- Update the database connection string in
config/config.go.
docker run --name fiber-auth -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=fiber_auth -p 5432:5432 -d postgres- Run the application:
go run main.go- Register a new user:
POST /register
Content-Type: application/json
{
"username": "example",
"password": "password123"
}-
Login:
POST /login Content-Type: application/json { "username": "example", "password": "password123" }
-
Access protected routes: Add the
Authorization: Bearer <token>header to your requests.
This project is licensed under the MIT License. See the LICENSE file for details.