keycloak-collective-portal/keycloak_collective_portal/oidc.py
decentral1se d22abd2bc5
All checks were successful
continuous-integration/drone/push Build is passing
The Big Refactor
Closes #3.
Closes #5.
Closes #7.
Closes #4.
Closes #2.
2021-06-13 12:20:16 +02:00

26 lines
693 B
Python

"""OpenID Connect logic."""
from authlib.integrations.starlette_client import OAuth, OAuthError
def init_oidc():
"""Initialise OIDC client."""
from keycloak_collective_portal.config import (
KEYCLOAK_BASE_URL,
KEYCLOAK_CLIENT_ID,
KEYCLOAK_CLIENT_SECRET,
KEYCLOAK_SCOPES,
)
oidc = OAuth()
oidc.register(
name="keycloak",
client_kwargs={"scope": KEYCLOAK_SCOPES},
client_id=KEYCLOAK_CLIENT_ID,
client_secret=KEYCLOAK_CLIENT_SECRET,
authorize_url=f"{KEYCLOAK_BASE_URL}/auth",
access_token_url=f"{KEYCLOAK_BASE_URL}/token",
jwks_uri=f"{KEYCLOAK_BASE_URL}/certs",
)
return oidc