Skip to main content

Extensions for django-allauth module to support groups of Keycloak.

Project description

django-allauth-keycloak-ext is a Python package that extends Django-allauth to support security groups configured in Keycloak.

Features

  • Supports adding/removing users from Django groups mapped to Keycloak groups during login procedure.

  • Supports mapping Keycloak groups to is_staff and is_superuser flags of Django users.

Installation

To install django-allauth-keycloak-ext, run the following command:

pip install django-allauth-keycloak-ext

Usage

Once you have installed django-allauth-keycloak-ext, you can use it in your Django project by following these steps:

  1. Add ‘allauth_keycloak_groups’ to your INSTALLED_APPS setting:

    INSTALLED_APPS = [
        # ...
        'allauth_keycloak_ext',
        # ...
    ]
  2. Configure Django-allauth to use Keycloak Ext as a provider by adding the following settings to your settings.py file:

    SOCIALACCOUNT_PROVIDERS = {
        "keycloak_ext": {
            "KEYCLOAK_URL": "http://localhost:8080",
            "KEYCLOAK_REALM": "master",
            "GROUPS": {
                "GROUP_TO_FLAG_MAPPING": {
                    "is_staff": ["Django Staff", "django-admin-role"],
                    "is_superuser": "django-admin-role",
                },
            }
        }
    }
  3. Configure the security groups you want to use in Keycloak and map them to Django groups in your settings.py file:

    ALLAUTH_KEYCLOAK_GROUPS = {
        'group-name-1': 'django-group-name-1',
        'group-name-2': 'django-group-name-2',
        # ...
    }

    Note that the keys of the ALLAUTH_KEYCLOAK_GROUPS dictionary should be the names of the security groups you have configured in Keycloak, and the values should be the names of the Django groups you want to map them to.

License

This package is released under the MIT License.

Contributing

Contributions to this project are welcome. Please submit bug reports

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-allauth-keycloak-ext-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-allauth-keycloak-ext-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django-allauth-keycloak-ext-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1f6f3a9a0fa1a2ff837d251b7736fb7945b837f22ef0dc4c37f45608c063f45d
MD5 cfa52bb09601971933812c754c89b630
BLAKE2b-256 55af3ced235ad40ecd9fc80fff1c70206fc377cc4c42a433352dafcdeca9f4e6

See more details on using hashes here.

File details

Details for the file django_allauth_keycloak_ext-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_allauth_keycloak_ext-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a208048bde1e6ffeea1ec83932e7e6f5d4f9dff2e651828efc2e70a3f3cb6daf
MD5 6433f435b60d44e86bc8f8e6c6d4f05a
BLAKE2b-256 daf15dbc6e37fb8790424b9a016caa4b50dbb83952e96778fcef4fd22ecc5feb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page