django-allauth-d120 is a provider for allauth to integrate d120 accounts into django projects. It therefor provides a wrapper around the allauth OAuth 2.0 provider and connects it with the keycloak OAuth 2.0 endpoint. The app allows to synchronize the groups of a user from keycloak to your django project.
- Install django-allauth-d120 with pip e.g.
pip install django-allauth django-allauth-d120
- Add the following apps to the installed
INSTALLED_APPS
in thesettings.py
:
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth_d120_provider',
- Configure the Authentication backends in the
settings.py
:
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',
)
- Configure allauth to disable email verification, account sing up outside the sso and
account sign up via the sso in the
settings.py
:
ACCOUNT_EMAIL_VERIFICATION = "none"
ACCOUNT_ADAPTER = "allauth_d120_provider.account_adapter.DisableSignUpAdapter"
SOCIALACCOUNT_ADAPTER = "allauth_d120_provider.account_adapter.SocialAccountAdapter"
- Run
manage.py migrate
to create sync the database with the newly installed apps - Login into the Django Admin webinterface to configure the website object. Therefore go to site section and
select the site model e.g. the url ends on
admin/sites/site/
whereadmin/
is the root path of Django Admin in your project. Make sure the domain matches the domain your project is running on. - Within Django Admin go to the Social Accounts section and select the Social applications model e.g. the url
ends on
admin/socialaccount/socialapp/
whereadmin/
is the root path of Django Admin in your project. Add a new instance which usesD120 OAuth 2.0
as provider. Please ask fss@ for a Client id and the related Secret Key. - Have a look at the instructions to install allauth. There might be steps necessary steps that are not mentioned in this instruction.
You can create a group synchronization by adding instances of the groupsync Model via Django Admin. Therefor select the Group Synchronization model in the D120 Autentication Provider section. The groups synchronize when the user logs into the project.