diff --git a/README.md b/README.md index 58cde129e22dc7d6d443cc379c80f5150962b182..bf28e69ed0b897c15a708c6ff467ebc4fc5f300b 100644 --- a/README.md +++ b/README.md @@ -110,3 +110,24 @@ This is the procedure for that. +#### Integrating Astronauth + +See the integration instructions in the [astronauth repo](https://git.astron.nl/astron-sdc/astronauth) + +After this the following considerations apply: + +* Log into the Django admin interface +* Make sure the Sites contains an entry +In the Social Accounts section, click add on Social applications and use the following settings + + +Provider => Keycloak + + +Name => Keycloak (could be anything) + +Client id => The Client ID configured in your Keycloak Realm. + +Secret => The Secret key provided by the Keycloak Realm in the Credentials tab + +Sites => Make sure the site is added, otherwise you will run into No providers available errors. diff --git a/atdb/atdb/settings/base.py b/atdb/atdb/settings/base.py index 24d55402edd2f75e738ae3bcd60b17466d72db2e..34afccd7d57b985c3745a4d1ef5d5abf5a7c664e 100644 --- a/atdb/atdb/settings/base.py +++ b/atdb/atdb/settings/base.py @@ -215,6 +215,13 @@ SERVICES_LATE_WARNING_SECONDS = 1800 # astronauth settings SITE_ID = 1 +AUTHENTICATION_BACKENDS = [ + # Needed to login by username in Django admin, regardless of `allauth` + "django.contrib.auth.backends.ModelBackend", + # `allauth` specific authentication methods, such as login by e-mail + "allauth.account.auth_backends.AuthenticationBackend", +] + SOCIALACCOUNT_PROVIDERS = { 'keycloak': { 'KEYCLOAK_URL': 'https://sdc-dev.astron.nl/auth', # replace by https://keycloak.astron.nl/auth for production @@ -223,5 +230,10 @@ SOCIALACCOUNT_PROVIDERS = { } } +try: + LOGIN_REDIRECT_URL = os.environ['LOGIN_REDIRECT_URL'] +except: + LOGIN_REDIRECT_URL = 'https://sdc-dev.astron.nl:5554/atdb/' + SESSION_COOKIE_NAME = 'my_service_name_session_id' CSRF_COOKIE_NAME = 'my_service_csrftoken' diff --git a/atdb/atdb/settings/dev.py b/atdb/atdb/settings/dev.py index 9bf71edbe457b50db79c21ce74b19ba03ba9f01f..8c9925a1c09fb042fa2979d79353f4c43a2247ad 100644 --- a/atdb/atdb/settings/dev.py +++ b/atdb/atdb/settings/dev.py @@ -24,6 +24,7 @@ DATABASES = { AUTH_PASSWORD_VALIDATORS = [] +# astronauth settings SOCIALACCOUNT_PROVIDERS = { 'keycloak': { 'KEYCLOAK_URL': 'https://sdc-dev.astron.nl/auth', # replace by https://keycloak.astron.nl/auth for production diff --git a/atdb/atdb/settings/docker_sdc.py b/atdb/atdb/settings/docker_sdc.py index 35ce0aaea3b8bf46b966d7536a43ee14c744be69..a4307fa8d426f4c197531ae667546a6f94222e7c 100644 --- a/atdb/atdb/settings/docker_sdc.py +++ b/atdb/atdb/settings/docker_sdc.py @@ -37,3 +37,4 @@ DATABASES = { AUTH_PASSWORD_VALIDATORS = [] +