Authentication service with OpenID Connect.
The static config files are stored as JSON files in $CONFIG_PATH with subdirectories for each tenant,
e.g. $CONFIG_PATH/default/*.json. The default tenant name is default.
- JSON schema
- File location:
$CONFIG_PATH/<tenant>/oidcAuthConfig.json
Example:
{
"$schema": "https://github.com/qwc-services/qwc-oidc-auth/raw/main/schemas/qwc-oidc-auth.json",
"service": "oidc-auth",
"config": {
"issuer_url": "https://qwc2-dev.onelogin.com/oidc/2",
"client_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxxx",
"client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}The service expects authentication service information at $ISSUER_URL/.well-known/openid-configuration
See the schema definition for the full set of supported config variables.
Config options in the config file can be overridden by equivalent uppercase environment variables.
It is possible to authorize connection with a external Access Token in the Authorization Header (endpoint /tokenlogin).
For each token a configuration needs to be add in authorized_api_token.
Example:
{
"$schema": "https://github.com/qwc-services/qwc-oidc-auth/raw/main/schemas/qwc-oidc-auth.json",
"service": "oidc-auth",
"config": {
"issuer_url": "https://qwc2-dev.onelogin.com/oidc/2",
"client_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxxx",
"client_secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"authorized_api_token": [{
"keys_url": "https://public_keys_url_to_decode_token",
"claims_options":{
"iss": {
"essential": true,
"values": ["https://example.com", "https://example.org"]
},
"sub": {
"essential": true,
"value": "xxxxxxxxxxxxx"
},
"aud": {
"essential": true,
"value": "api://xxxx-xxxxxxxxx-xxxxx"
}
}
}]
}
}claims_options are the token validation parameters which allow fine control over the content of the payload. See https://docs.authlib.org/en/latest/jose/jwt.html#jwt-payload-claims-validation.
CLIENT_ID and CLIENT_SECRET are defined on identity provider side.
The redirect URI is the public base URL with the endpoint /callback (Example: https://qwc2.sourcepole.ch/oauth/callback).
This redirect URI can be manually configured with redirect_uri.
To end the OpenID session on when /logout is called, set "end_session_on_logout": true in the service config.
If your OpenID provider does not provide a end_session_endpoint in the .well-known/openid-configuration, you can set a custom logout URL via session_logout_url.
Install dependencies and run:
export CONFIG_PATH=<CONFIG_PATH>
uv run src/server.py
To use configs from a qwc-docker setup, set CONFIG_PATH=<...>/qwc-docker/volumes/config.
Set FLASK_DEBUG=1 for additional debug output.
Set FLASK_RUN_PORT=<port> to change the default port (default: 5000).
The Docker image is published on Dockerhub.
See sample docker-compose.yml of qwc-docker.