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.0rc9.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

garpix_keycloak-1.3.0rc9-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: garpix_keycloak-1.3.0rc9.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/7.0.2 pkginfo/1.10.0 requests/2.31.0 requests-toolbelt/1.0.0 tqdm/4.66.2 CPython/3.10.13

File hashes

Hashes for garpix_keycloak-1.3.0rc9.tar.gz
Algorithm Hash digest
SHA256 63f5b6c35a4ab6e6ae6012821683176b398880cbbfe1a471115a208012b11dbe
MD5 d2d66503096b2e31d3ce35f743b6eabb
BLAKE2b-256 60c4aac042d9b379f2c209a0974286d0e14f723208f3bd5c608117be587adeaf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: garpix_keycloak-1.3.0rc9-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/7.0.2 pkginfo/1.10.0 requests/2.31.0 requests-toolbelt/1.0.0 tqdm/4.66.2 CPython/3.10.13

File hashes

Hashes for garpix_keycloak-1.3.0rc9-py3-none-any.whl
Algorithm Hash digest
SHA256 4f8da005f133134dd39072489dbbf016421aa1bd36f4847dc17ba9b40ae68acc
MD5 6e33138f4e0503178f5a75c03e854470
BLAKE2b-256 fc0cffabcae2b74e25faf1746c10eb89f425d5136989b186faf7eb66f5271ba7

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