A Spring Boot microservice that provides authentication services for the Flexo Model Management System (MMS). This service supports OAuth2/OIDC authentication, API key management, and JWT generation.
- OAuth2/OIDC authentication integration
- API key management for service-to-service communication
- JWT token generation and validation
- User profile information retrieval
- Database support for both SQLite (development) and PostgreSQL (production)
- Java 17 or higher
- Gradle 7.6+ (or use the included Gradle wrapper)
- SQLite for development or PostgreSQL for production
-
Clone the repository:
git clone https://github.com/Open-MBEE/flexo-mms-sso-auth-service.git cd flexo-mms-sso-auth-service
-
Build the project:
./gradlew build
-
Run the application:
./gradlew bootRun
The service will be available at http://localhost:3000.
The application can be configured through application.yml
. Key configuration options:
spring:
datasource:
url: jdbc:sqlite:sso-database.db # NOTE: This requires a writeable mount
# For PostgreSQL use:
# url: jdbc:postgresql://localhost:5432/sso_db
# username: your_username
# password: your_password
security:
oauth2:
client:
registration:
oidc:
client-id: your-client-id
client-secret: your-client-secret
redirect_uri: http://localhost:3000/login/oauth2/code/oidc
provider:
oidc:
issuer-uri: https://your-identity-provider/
NOTE: All configuration options are mapped to environment variables that replace all special characters with underscore ("_"). For instance, flexo.sso-auth-service.sso_user_id_field
would map to the environment variable FLEXO_SSO_AUTH_SERVICE_SSO_USER_ID_FIELD
.
docker pull openmbee/flexo-mms-sso-auth-service:latest
Build the Docker image with:
docker build -t flexo-mms-sso-auth-service .
A docker-compose.yml
file is provided for easy deployment:
docker-compose up
This will start both the SSO service and a mock OIDC server for testing.
When running with Docker, you can override settings with environment variables:
docker run -p 8080:8080 \
-e SPRING_PROFILES_ACTIVE=docker \
-e SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/sso_db \
-e SPRING_DATASOURCE_USERNAME=postgres \
-e SPRING_DATASOURCE_PASSWORD=password \
-e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID=your-client-id \
-e SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET=your-client-secret \
-e SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI=https://your-identity-provider/ \
-e FLEXO_SSO_AUTH_SERVICE_SSO_USER_ID_FIELD: username \
-e FLEXO_SSO_AUTH_SERVICE_SSO_GROUP_CLAIMS_FIELD: groups \
flexo-mms-sso-auth-service
- Register an application with your OIDC provider (Auth0, Okta, Keycloak, etc.)
- Configure the callback URL:
http://your-service-domain/login/oauth2/code/oidc
- Update
application.yml
or environment variables with:- Client ID
- Client Secret
- Issuer URI
The service maps OIDC claims to user information and groups:
flexo:
sso-auth-service:
sso_user_id_field: "sub"
jwt_user_id_field: "preferred_username"
group_claims_field: "groups"
NOTE: All configuration options are mapped to environment variables that replace all special characters with underscore ("_"). For instance, flexo.sso-auth-service.sso_user_id_field
would map to the environment variable FLEXO_SSO_AUTH_SERVICE_SSO_USER_ID_FIELD
.
sso_user_id_field
: Field in the ID token used as the primary user identifierjwt_user_id_field
: Field to use as the username in issued JWTs (Typically the same as sso_user_id_field)group_claims_field
: Field containing user groups/roles
GET /login
: Initiates OIDC authentication flowGET /login?apiKey={key}
: Authenticates using an API keyGET /check
: Validates the current authenticationGET /api/userinfo
: Returns information about the current user
Navigate to http://your-service-domain/user in order to manage and create API keys
It is possible to serve this application on a url prefix, i.e. from a reverse proxy. Simply define the environment variable as follows:
export SERVER_SERVLET_CONTEXT_PATH=/sso
Ensure that the given string begins with a "/" and ends without the trailing "/".
./gradlew test
This project is licensed under the Apache License 2.0.