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',
]
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
Developed by Garpix / https://garpix.com
Metadata
Release files for garpix-keycloak 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| garpix_keycloak-1.2.1.tar.gz | 8.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| garpix_keycloak-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.6 kB
Release files / garpix_keycloak-1.2.1.tar.gz
| Download URL | garpix_keycloak-1.2.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9e1ae1654e7abc580958ea7f13de08e243eba54175068b166afb646e6a77e1f
|
|
BLAKE2b-256 checksum How to use checksums |
07cf619f6a362ac5316584a4274e747d5a6834c631b786b47b101af3ad554f4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / garpix_keycloak-1.2.1-py3-none-any.whl
| Download URL | garpix_keycloak-1.2.1-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4bd756fe1253f70c2d552f3c40878671fe6095e3ea42098e7233d5f7a6425956
|
|
BLAKE2b-256 checksum How to use checksums |
01ac92be7cdb89deb6a920ee27a8e4f5cb843095aff0fd95811df29877892cae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|