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 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
Hashes for garpix_keycloak-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dac8887d4be3de7fe5c8eae4ece23fd41889b6b2e774082875c0d7606f82418c |
|
MD5 | d93d2740cda99d50736fe5f46a65dc0f |
|
BLAKE2b-256 | f0655d16202af025005826159b1b6135b2aa867e9f749dc6576c29176b8dcc96 |