django-allauth-keycloak-ext


Namedjango-allauth-keycloak-ext JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/wonderu/allauth-keycloak-ext/
SummaryExtensions for django-allauth module to support groups of Keycloak.
upload_time2023-03-19 16:56:37
maintainer
docs_urlNone
authorIgor Podsekin
requires_python>=3.8
license
keywords django auth account social openid twitter facebook oauth registration
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            django-allauth-keycloak-ext
==============================

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.
- Supports mapping of Keycloak groups to Django ones.

Installation
------------

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

.. code-block:: bash

    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:

   .. code-block:: python

       INSTALLED_APPS = [
           # ...
           'allauth_keycloak_ext',
           # ...
       ]

2. Configure Django-allauth to use Keycloak Ext as a provider and map flags to Keycloak groups by adding the following settings to your `settings.py` file:

   .. code-block:: python

        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:

   .. code-block:: python

       SOCIALACCOUNT_PROVIDERS = {
            "keycloak_ext": {
                "KEYCLOAK_URL": "http://localhost:8080",
                "KEYCLOAK_REALM": "master",
                "GROUPS": {
                    ...
                    "GROUPS_MAPPING": {
                        "django-admin-role": "django-admin-group",
                        "offline_access": "Offline Group",
                    }
                    ...
                },
            }
        }

   Note that the keys of the `GROUPS_MAPPING` 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.

4. Configure auto creation of the security groups in Django in your `settings.py` file:
    .. code-block:: python

        SOCIALACCOUNT_PROVIDERS = {
            "keycloak_ext": {
                "KEYCLOAK_URL": "http://localhost:8080",
                "KEYCLOAK_REALM": "master",
                "GROUPS": {
                    ...
                    "GROUPS_MAPPING": {
                        "django-admin-role": "django-admin-group",
                        "offline_access": None,
                    },
                    "GROUPS_AUTO_CREATE": True,
                },
            }
        }

    Note that you can disable creating of any group by mapping them to `None`. 


Usage Example
-------------

https://github.com/wonderu/keycloak-django - test application

License
-------

This package is released under the MIT License.

Contributing
------------

Contributions to this project are welcome. Please submit bug reports

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/wonderu/allauth-keycloak-ext/",
    "name": "django-allauth-keycloak-ext",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "django auth account social openid twitter facebook oauth registration",
    "author": "Igor Podsekin",
    "author_email": "py@wonderu.com",
    "download_url": "https://files.pythonhosted.org/packages/42/de/fb4674e1df344001de9c2130410f170293fcefba2317f229fb3cd78f8813/django-allauth-keycloak-ext-0.1.2.tar.gz",
    "platform": null,
    "description": "django-allauth-keycloak-ext\n==============================\n\ndjango-allauth-keycloak-ext is a Python package that extends Django-allauth to support security groups configured in Keycloak.\n\nFeatures\n--------\n\n- Supports adding/removing users from Django groups mapped to Keycloak groups during login procedure.\n- Supports mapping Keycloak groups to is_staff and is_superuser flags of Django users.\n- Supports mapping of Keycloak groups to Django ones.\n\nInstallation\n------------\n\nTo install django-allauth-keycloak-ext, run the following command:\n\n.. code-block:: bash\n\n    pip install django-allauth-keycloak-ext\n\nUsage\n-----\n\nOnce you have installed django-allauth-keycloak-ext, you can use it in your Django project by following these steps:\n\n1. Add `'allauth_keycloak_groups'` to your `INSTALLED_APPS` setting:\n\n   .. code-block:: python\n\n       INSTALLED_APPS = [\n           # ...\n           'allauth_keycloak_ext',\n           # ...\n       ]\n\n2. Configure Django-allauth to use Keycloak Ext as a provider and map flags to Keycloak groups by adding the following settings to your `settings.py` file:\n\n   .. code-block:: python\n\n        SOCIALACCOUNT_PROVIDERS = {\n            \"keycloak_ext\": {\n                \"KEYCLOAK_URL\": \"http://localhost:8080\",\n                \"KEYCLOAK_REALM\": \"master\",\n                \"GROUPS\": {\n                    \"GROUP_TO_FLAG_MAPPING\": {\n                        \"is_staff\": [\"Django Staff\", \"django-admin-role\"],\n                        \"is_superuser\": \"django-admin-role\",\n                    },\n                }\n            }\n        }\n\n3. Configure the security groups you want to use in Keycloak and map them to Django groups in your `settings.py` file:\n\n   .. code-block:: python\n\n       SOCIALACCOUNT_PROVIDERS = {\n            \"keycloak_ext\": {\n                \"KEYCLOAK_URL\": \"http://localhost:8080\",\n                \"KEYCLOAK_REALM\": \"master\",\n                \"GROUPS\": {\n                    ...\n                    \"GROUPS_MAPPING\": {\n                        \"django-admin-role\": \"django-admin-group\",\n                        \"offline_access\": \"Offline Group\",\n                    }\n                    ...\n                },\n            }\n        }\n\n   Note that the keys of the `GROUPS_MAPPING` 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.\n\n4. Configure auto creation of the security groups in Django in your `settings.py` file:\n    .. code-block:: python\n\n        SOCIALACCOUNT_PROVIDERS = {\n            \"keycloak_ext\": {\n                \"KEYCLOAK_URL\": \"http://localhost:8080\",\n                \"KEYCLOAK_REALM\": \"master\",\n                \"GROUPS\": {\n                    ...\n                    \"GROUPS_MAPPING\": {\n                        \"django-admin-role\": \"django-admin-group\",\n                        \"offline_access\": None,\n                    },\n                    \"GROUPS_AUTO_CREATE\": True,\n                },\n            }\n        }\n\n    Note that you can disable creating of any group by mapping them to `None`. \n\n\nUsage Example\n-------------\n\nhttps://github.com/wonderu/keycloak-django - test application\n\nLicense\n-------\n\nThis package is released under the MIT License.\n\nContributing\n------------\n\nContributions to this project are welcome. Please submit bug reports\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Extensions for django-allauth module to support groups of Keycloak.",
    "version": "0.1.2",
    "split_keywords": [
        "django",
        "auth",
        "account",
        "social",
        "openid",
        "twitter",
        "facebook",
        "oauth",
        "registration"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "544353cd10b8649b20de6afeb4d14e35e29d6482d8eab68ff2bfeb573ce5dce3",
                "md5": "fc301c64e62267cb51c15f3cc40fa7d4",
                "sha256": "db0c6db149056d874ebacf9558e33976657db2fed77b0fa01ba84bfdbc89a57b"
            },
            "downloads": -1,
            "filename": "django_allauth_keycloak_ext-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fc301c64e62267cb51c15f3cc40fa7d4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6308,
            "upload_time": "2023-03-19T16:56:36",
            "upload_time_iso_8601": "2023-03-19T16:56:36.276784Z",
            "url": "https://files.pythonhosted.org/packages/54/43/53cd10b8649b20de6afeb4d14e35e29d6482d8eab68ff2bfeb573ce5dce3/django_allauth_keycloak_ext-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "42defb4674e1df344001de9c2130410f170293fcefba2317f229fb3cd78f8813",
                "md5": "8de109f6993ad9add2cad4c134eaf5f5",
                "sha256": "b9e1f5bc4081f059dd8f7c6e6e30680a68e8bd4f9b808a89e31a4acf12fdaea4"
            },
            "downloads": -1,
            "filename": "django-allauth-keycloak-ext-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "8de109f6993ad9add2cad4c134eaf5f5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 6678,
            "upload_time": "2023-03-19T16:56:37",
            "upload_time_iso_8601": "2023-03-19T16:56:37.974373Z",
            "url": "https://files.pythonhosted.org/packages/42/de/fb4674e1df344001de9c2130410f170293fcefba2317f229fb3cd78f8813/django-allauth-keycloak-ext-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-19 16:56:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "wonderu",
    "github_project": "allauth-keycloak-ext",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-allauth-keycloak-ext"
}
        
Elapsed time: 0.04476s