Skip to content

Commit

Permalink
Copy forgotten parameters to the default_settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Rusakov authored and lanseg committed Oct 14, 2024
1 parent 14183ae commit 11f9780
Showing 1 changed file with 12 additions and 8 deletions.
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

0 comments on commit 11f9780

Please sign in to comment.