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.0.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.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_admin_keycloak-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 ac5d5950b549b5314724d75e5189abd276f22d9f821d67ec11a942d13382370a
MD5 f711e12433cfc876f9a7903a2c62f583
BLAKE2b-256 7217e030e933c36f1944b487bb3b2c750d4b1afc8fb8dc297fa13f6eed1fe016

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_admin_keycloak-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 459554e5f4d245bde3c9d285d014284c7aec520b4339aeffe8b6d651e802ae41
MD5 f9d346b38ee12355c5cae74367ed1bdb
BLAKE2b-256 e5f56e106d6fe738154fa4a5d8b99f42d05b20ccdee8fa06d4ec2efa389f52b3

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