Skip to main content

Django Admin Keycloak

Project description

django-admin-keycloak

Keycloak

Create Client OpenID with callback url https://keycloak.example.ru/sso/* add client scopes "roles" and set client Backchannel logout URL https://keycloak.example.ru/sso/logout

Settings

# define static config or add provider later in admin management
KEYCLOAK_PROVIDERS = [
    {
        'slug': 'local', # internal django slug
        'name': 'Local', # name on login form
        'client_id': 'local_django',
        'client_secret': 'SECRET',
        'redirect_uri': '/admin', # redirect uri after login
        'server_url': 'https://keycloak.example.ru',
        'realm_name': 'django',
        'role_staff_user': 'dev_staff', # role for staff users
        'role_super_user': 'dev_super_user', # role for superusers
    }
]

Add to INSTALLED_APPS

INSTALLED_APPS = [
    'django_admin_keycloak',
    'django.contrib.admin',
    # ...
]

Add to urls.py

urlpatterns = [
    # ...,
    path('sso/', include('django_admin_keycloak.url')),
    # ...
]

If you define static config, you must execute command for update providers.

python manage.py update_static_providers

Available signals

user_sso_login

On login SSO user
  • session: KeycloakSession
  • request: HttpRequest
  • userinfo: dict
  • access_token: str

user_sso_logout

On logout SSO user
  • session: KeycloakSession
  • request: HttpRequest

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_admin_keycloak-1.0.1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_admin_keycloak-1.0.1-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file django_admin_keycloak-1.0.1.tar.gz.

File metadata

  • Download URL: django_admin_keycloak-1.0.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for django_admin_keycloak-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d2f7adfbec5d07f45f429551f2999d878ca78b6e2a728e767a70f8171e1a28ce
MD5 162677ad1f9f04492640b070766a4a85
BLAKE2b-256 bfe0c8763bc8db189e8556725346eed9454b583a447e128bf69644a2a6b1836a

See more details on using hashes here.

File details

Details for the file django_admin_keycloak-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_keycloak-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9d8e5900a344f0d757d17b2083a45cfe6cfd8f38bc9de7c56a42953ae1d6e296
MD5 ba5676c909e749f8b4f9679f166c0216
BLAKE2b-256 8b91de2c73f0c63a4a342b0cac04e52424897fd689f432107a277be04238d447

See more details on using hashes here.

Supported by

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