Skip to content
Snippets Groups Projects
Verified Commit 8b8e1583 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Configure default scopes for OAuth even without OpenID Connect support

parent 2ec420bc
No related branches found
No related tags found
1 merge request!586Enable the Django REST framework
......@@ -271,25 +271,34 @@ AUTHENTICATION_BACKENDS = []
# Configuration for OAuth2 provider
oidc_enabled = _settings.get("oauth2.oidc.enabled", False)
OAUTH2_PROVIDER = {
"SCOPES": {
"read": "Read anything the resource owner can read",
"write": "Write anything the resource owner can write",
}
}
if oidc_enabled:
if _settings.get("oauth2.oidc.enabled", False):
with open(_settings.get("oauth2.oidc.rsa_key", "/etc/aleksis/oidc.pem"), "r") as f:
oid_rsa_key = f.read()
OAUTH2_PROVIDER = {
"OAUTH2_VALIDATOR_CLASS": "aleksis.core.util.auth_helpers.CustomOAuth2Validator",
"OIDC_ENABLED": oidc_enabled,
"OIDC_RSA_PRIVATE_KEY": oid_rsa_key,
# "OIDC_ISS_ENDPOINT": _settings.get("oauth2.oidc.issuer_name", "example.com"),
"SCOPES": {
OAUTH2_PROVIDER.update(
{
"OAUTH2_VALIDATOR_CLASS": "aleksis.core.util.auth_helpers.CustomOAuth2Validator",
"OIDC_ENABLED": True,
"OIDC_RSA_PRIVATE_KEY": oid_rsa_key,
# "OIDC_ISS_ENDPOINT": _settings.get("oauth2.oidc.issuer_name", "example.com"),
}
)
OAUTH2_PROVIDER["SCOPES"].update(
{
"openid": "OpenID Connect scope",
"profile": "Profile scope",
"phone": "Phone scope",
"email": "Email scope",
"address": "Address scope",
},
}
}
)
# Configuration for REST framework
REST_FRAMEWORK = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment