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',
]
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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file garpix_keycloak-1.3.0rc8.tar.gz.
File metadata
- Download URL: garpix_keycloak-1.3.0rc8.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.0 pkginfo/1.9.6 requests/2.31.0 requests-toolbelt/1.0.0 tqdm/4.66.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c223b120cccbabca67fbb08f2b70d3896bfb206bbd22aa94e45b6c0cc8d17e37
|
|
| MD5 |
347bbc055f45d1b7ad42b8cd880d678b
|
|
| BLAKE2b-256 |
f45cd54804aaed89dc365bf486192143ab0c4d92583932b108a184d4388a241e
|
File details
Details for the file garpix_keycloak-1.3.0rc8-py3-none-any.whl.
File metadata
- Download URL: garpix_keycloak-1.3.0rc8-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/7.0.0 pkginfo/1.9.6 requests/2.31.0 requests-toolbelt/1.0.0 tqdm/4.66.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d7e18be6686df872fb9e51c66c0e8cd54d58f5eb29cbd66df069e27bcf8047a
|
|
| MD5 |
6ebee6c4d245ad34b302de2ff78af543
|
|
| BLAKE2b-256 |
3d41b9a4e91df62fab5d24ef7c35be07349fee4494155a8b60e52811655b8f6a
|