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
Built Distribution
File details
Details for the file garpix_keycloak-1.0.0.tar.gz
.
File metadata
- Download URL: garpix_keycloak-1.0.0.tar.gz
- Upload date:
- Size: 7.1 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.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 802737701b242cd01599dda664e64216a83838676770625dc836285131fe8c7e |
|
MD5 | 046c921f82e207d4ddfc3c04c103006e |
|
BLAKE2b-256 | fb2257d4fe689e6fdbcc4c4663ac04657c35485167d57ebe1ec3a8e77fd91e95 |
File details
Details for the file garpix_keycloak-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: garpix_keycloak-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.0 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.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9923f4653a6bcca630b3f943603dbda9a895cd974f75c10bdfdbae4b8a7b6ffa |
|
MD5 | 3f60539694f8f3be5bbb60e1c01f9cd9 |
|
BLAKE2b-256 | 3000c4b261ac8c848335629eb06d14484c33c66fa2f9c252105ef5dc0b775247 |