Skip to content

PTSS-Support/Authentication-Service

Repository files navigation

Authentication Service

Authentication and authorization service for PTSS Support, built with Go and Keycloak.

Framework Choices

  • Gin: High-performance HTTP web framework
  • Viper: Configuration management
  • Keycloak: Enterprise-grade identity management

Getting Started

  1. Clone the repository
git clone https://github.com/ptss-support/authentication-service.git
cd authentication-service
  1. Install dependencies
go mod tidy
  1. 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.

  1. Start keycloak server
docker compose up
  1. Configure Keycloak

This should be done automatically. If not follow the Keycloak Setup Guide for more informaiton + troubleshooting sections.

  1. Run the application
go run cmd/main.go

API Testing

Caution

Need to be adjusted!

  1. 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"
  }'
  1. Login
curl -X POST http://localhost:8081/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "password123"
  }'
  1. Get user info
# Replace TOKEN with the access token from login response
curl -X GET http://localhost:8081/auth/me \
  -H "Authorization: Bearer TOKEN"

About

Authentication and authorization service for PTSS Support

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors