Authentication and authorization service for PTSS Support, built with Go and Keycloak.
- Gin: High-performance HTTP web framework
- Viper: Configuration management
- Keycloak: Enterprise-grade identity management
- Clone the repository
git clone https://github.com/ptss-support/authentication-service.git
cd authentication-service
- Install dependencies
go mod tidy- Configure Environment Variables
For local development, create a .env file in the root directory of the project. You can use the provided .env.example as a template.
- Start keycloak server
docker compose up- Configure Keycloak
This should be done automatically. If not follow the Keycloak Setup Guide for more informaiton + troubleshooting sections.
- Run the application
go run cmd/main.goCaution
Need to be adjusted!
- Create a new user
curl -X POST http://localhost:8081/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "password123",
"firstName": "John",
"lastName": "Doe",
"role": "patient"
}'- Login
curl -X POST http://localhost:8081/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "password123"
}'- Get user info
# Replace TOKEN with the access token from login response
curl -X GET http://localhost:8081/auth/me \
-H "Authorization: Bearer TOKEN"