No project description provided
Project description
Garpix Keycloak
Keycloak uth module for Django/DRF projects. Part of GarpixCMS.
Used packages:
- django rest framework
- etc; see setup.py
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',
]
Now when your request has Bearer
token, it would be firstly checked as base django user token, then as keycloak token.
Enjoy!
Changelog
See CHANGELOG.md.
Contributing
See CONTRIBUTING.md.
License
Developed by Garpix / https://garpix.com
Project details
Release history Release notifications | RSS feed
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.0.0.tar.gz
(7.1 kB
view hashes)
Built Distribution
Close
Hashes for garpix_keycloak-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9923f4653a6bcca630b3f943603dbda9a895cd974f75c10bdfdbae4b8a7b6ffa |
|
MD5 | 3f60539694f8f3be5bbb60e1c01f9cd9 |
|
BLAKE2b-256 | 3000c4b261ac8c848335629eb06d14484c33c66fa2f9c252105ef5dc0b775247 |