This Golang-based authentication service provides a secure and reliable solution for user authentication, utilizing PostgreSQL as the backend database. The service includes a well-documented API, powered by Swagger annotations, making it easy for developers to integrate authentication into their applications.
- User registration and login
- Secure password hashing and storage
- JWT token generation for authenticated users
- Swagger-documented API for easy integration and development
To run this authentication service, ensure you have the following prerequisites installed:
- Go programming language
- PostgreSQL database
- Clone the repository:
git clone https://github.com/rf-krcn/authentication-service.git
cd authentication-service
- Install dependencies:
go install ./...
- Configuration
Configure the service by setting up the PostgreSQL connection details by editing the DSN in the main.go file.
- Run project
go run ./cmd
Example API usage:
# Register a new user and obtain JWT token
curl -X POST http://localhost:8080/register -d '{"username": "exampleuser", "password": "securepassword"}'
# Login and obtain JWT token
curl -X POST http://localhost:8080/login -d '{"username": "exampleuser", "password": "securepassword"}'
# Reset password
curl -X POST http://localhost:8080/reset_password -d '{"user_name": "exampleuser", "password": "securepassword", "new_password": "newsecurepassword"}'
For more detailed information, refer to the API Documentation section.
The API is thoroughly documented using Swagger annotations. Access the Swagger UI at http://localhost:8080/docs/index.html to explore and interact with the API.