Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSGGR-154 Copy forgotten parameters to the default_settings.py #49

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@
},
}

AUTHENTICATION_BACKENDS = ("django.contrib.auth.backends.ModelBackend",)


# OIDC configuration
def discover_endpoints(discovery_url: str) -> dict:

Expand All @@ -303,9 +306,6 @@ def discover_endpoints(discovery_url: str) -> dict:
"introspection_endpoint": provider_config["introspection_endpoint"],
}

AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
)

def check_oidc() -> bool:
if os.environ.get("OIDC_ENABLED", "False") == "False":
Expand All @@ -322,25 +322,29 @@ def check_oidc() -> bool:
if OIDC_ENABLED:
INSTALLED_APPS.append('mozilla_django_oidc')
MIDDLEWARE.append('mozilla_django_oidc.middleware.SessionRefresh')
AUTHENTICATION_BACKENDS = ("oidc.PermissionBackend", ) + AUTHENTICATION_BACKENDS
AUTHENTICATION_BACKENDS = ('oidc.PermissionBackend',) + AUTHENTICATION_BACKENDS
REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = (
"oidc.PermissionBackend",
) + REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"]

OIDC_RP_CLIENT_ID = os.environ.get("OIDC_RP_CLIENT_ID")
ZITADEL_PROJECT = os.environ.get("ZITADEL_PROJECT")
OIDC_RP_CLIENT_SECRET = os.environ.get("OIDC_RP_CLIENT_SECRET")
OIDC_OP_BASE_URL = os.environ.get("OIDC_OP_BASE_URL")
OIDC_PRIVATE_KEYFILE = os.environ.get("OIDC_PRIVATE_KEYFILE")

OIDC_RP_SIGN_ALGO = "RS256"
OIDC_RP_SCOPES = "openid profile email address phone"
OIDC_OP_DISCOVERY_ENDPOINT = OIDC_OP_BASE_URL + "/.well-known/openid-configuration"
OIDC_USE_PKCE = True

discovery_info = discover_endpoints(OIDC_OP_DISCOVERY_ENDPOINT)
discovery_info = discover_endpoints(
OIDC_OP_BASE_URL + "/.well-known/openid-configuration"
)
OIDC_INTROSPECT_URL = discovery_info["introspection_endpoint"]
OIDC_OP_AUTHORIZATION_ENDPOINT = discovery_info["authorization_endpoint"]
OIDC_OP_TOKEN_ENDPOINT = discovery_info["token_endpoint"]
OIDC_OP_USER_ENDPOINT = discovery_info["userinfo_endpoint"]
OIDC_OP_JWKS_ENDPOINT = discovery_info["jwks_uri"]
OIDC_OP_AUTHORIZATION_ENDPOINT = discovery_info["authorization_endpoint"]
OIDC_PRIVATE_KEYFILE = os.environ.get("OIDC_PRIVATE_KEYFILE")

LOGIN_REDIRECT_URL = os.environ.get("OIDC_REDIRECT_BASE_URL") + "/oidc/callback"
LOGOUT_REDIRECT_URL = os.environ.get("OIDC_REDIRECT_BASE_URL") + "/"
Expand Down
Loading