Integration with Keycloak for user authentication

Tabla de contenidos

Athento has integration with Keycloak, with several use cases already operational. Below is described how to configure the Athento Keycloak integration.

Access the environment and go to Advanced options:

On that page, search for “Keycloak”:

Create server

Create a server using the Auth URL corresponding to the same Keycloak environment:

Create Realm

Create a Realm and select the server you previously created:

With the created Realm selected, reload the internal configurations:

IMPORTANT: perform these steps without logging out. If you log out, you will not be able to log back in (via SSO):

  1. Refresh OpenID Connect .well-known (this updates the parameters of the "well known oidc" field in "realms")
  2. Refresh Certificates
  3. Clear client tokens

Configuration in settings_custom/local_settings.py

For these steps, if you do not have access to the server, request management through soporte@athento.com.

Next, modify the configuration in the file: /var/www/athentose/athentose/settings_custom/local_settings.py

and add the following properties:

LOGIN_URL = 'keycloak_login'
KEYCLOAK = True
USE_KEYCLOAK = True
KEYCLOAK_CREATE_USER = True
LOGIN_PAGE_URI = '/keycloak/login'
DEFAULT_KEYCLOAK_USER_TEAM_ID = 1

In the AUTHENTICATION_BACKENDS property, add:

athentose.auth_backends.backends.AthentoSEKeycloakAuthorizationCodeBackend

In the MIDDLEWARE property, add:

django_keycloak.middleware.BaseKeycloakMiddleware

Finally, perform a reload of the services with: /var/www/athentose; ./scripts/soft_reload.sh