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-0.4.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_admin_keycloak-0.4.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for django_admin_keycloak-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b64984b21877d94179d36d941d7ad7d92dd9d808947c26cea7478a05b3f712c0
MD5 4d6d166f2a72f8bd9d245dd7d1af51fb
BLAKE2b-256 b042b14620eb15df18208c6daec3517796ee7594ee221c591fc603114a1a8775

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_admin_keycloak-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cf6aa787c4a269da6d6518e8234a44bd8f7278036641768fd5e9cac287b47d1
MD5 dee117cae98024f2fe2fa67c57e26b99
BLAKE2b-256 ed1a29581281ab936126304746287cc653f65f059a68afd364da76c6ec0e959e

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