Skip to main content

No project description provided

Project description

Garpix Keycloak

Keycloak uth module for Django/DRF projects. Part of GarpixCMS.

Used packages:

Quickstart

Install with pip:

pip install garpix_keycloak

Add the garpix_keycloak to your INSTALLED_APPS:

# settings.py

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

Add KeycloakUserMixin to your User model:

from django.contrib.auth.models import AbstractUser

from garpix_keycloak.mixins import KeycloakUserMixin


class User(AbstractUser, KeycloakUserMixin):

    class Meta:
        verbose_name = 'Пользователь'
        verbose_name_plural = 'Пользователи'

    def __str__(self):
        return self.username

Add KeycloakAuthMiddleware to MIDDLEWARE settings after django.contrib.auth.middleware.AuthenticationMiddleware:

# settings.py


MIDDLEWARE = [
    # ...
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'garpix_keycloak.middlewares.KeycloakAuthMiddleware',
]

Add authentication backend:

AUTHENTICATION_BACKENDS = [
    # ...
    'garpix_keycloak.backends.KeycloakAuthenticationBackend'
]

Add keycloak parameters to settings.py:

# settings.py


KEYCLOAK = {
    'SERVER_URL': 'your_server_url',
    'REALM': 'your_realm',
    'CLIENT_ID': 'your_client_id',
    'CLIENT_SECRET_KEY': 'your_client_secret_key'
}

Use get_keycloak_url from KeycloakService to generate keycloak log in link.

garpix_keycloak creates User model instance, using create_keycloak_user class method. You can override it if you need some customization in your project.

Enjoy!

Changelog

See CHANGELOG.md.

Contributing

See CONTRIBUTING.md.

License

MIT


Developed by Garpix / https://garpix.com

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

garpix_keycloak-1.3.0rc6.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

garpix_keycloak-1.3.0rc6-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file garpix_keycloak-1.3.0rc6.tar.gz.

File metadata

  • Download URL: garpix_keycloak-1.3.0rc6.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/6.0.0 pkginfo/1.9.6 requests/2.28.2 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.10.13

File hashes

Hashes for garpix_keycloak-1.3.0rc6.tar.gz
Algorithm Hash digest
SHA256 51e9119ac83c7fa214c8fc475c66b62488c6a15aec5c9a1e60a02fb30ec74244
MD5 dd12dcb1f003afe4bc4228c2e354cea5
BLAKE2b-256 b9915e22434f6c7270187cc7e3c020ec0b25f75588afd0734b4cef8c407d91e3

See more details on using hashes here.

File details

Details for the file garpix_keycloak-1.3.0rc6-py3-none-any.whl.

File metadata

  • Download URL: garpix_keycloak-1.3.0rc6-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/6.0.0 pkginfo/1.9.6 requests/2.28.2 requests-toolbelt/0.10.1 tqdm/4.64.1 CPython/3.10.13

File hashes

Hashes for garpix_keycloak-1.3.0rc6-py3-none-any.whl
Algorithm Hash digest
SHA256 b4494cea9b64fbf34bc0c0c00fd1d1ed9838a8faf0412fa2f0a5649acec9ce93
MD5 f89f5adf6188db9f5c782e251284a0f1
BLAKE2b-256 84edc617c716d0570a5ba7a06bfaaaa0c4483ccaca25dece28dbdf63bc9913a2

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