keycloak init

This commit is contained in:
Pratyush Desai 2022-01-08 13:15:24 +05:30
parent 47bbec8dfe
commit f00f36fba3
Signed by: pratyush
GPG Key ID: DBA5BB7505946FAD
4 changed files with 24 additions and 1 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ venv/
.vscode/ .vscode/
__pycache__/ __pycache__/
db.sqlite3 db.sqlite3
.env

View File

@ -1,7 +1,19 @@
asgiref==3.4.1 asgiref==3.4.1
certifi==2021.10.8
charset-normalizer==2.0.10
Django==4.0 Django==4.0
django-keycloak==0.1.2.dev0
djangorestframework==3.13.1 djangorestframework==3.13.1
ecdsa==0.17.0
idna==3.3
psycopg2==2.9.2 psycopg2==2.9.2
pyasn1==0.4.8
Pygments==2.11.2 Pygments==2.11.2
python-jose==3.3.0
python-keycloak-client==0.2.3
pytz==2021.3 pytz==2021.3
requests==2.27.1
rsa==4.8
six==1.16.0
sqlparse==0.4.2 sqlparse==0.4.2
urllib3==1.26.8

View File

@ -41,6 +41,7 @@ INSTALLED_APPS = [
'snippets.apps.SnippetsConfig', 'snippets.apps.SnippetsConfig',
'blog.apps.BlogConfig', 'blog.apps.BlogConfig',
'api.apps.ApiConfig', 'api.apps.ApiConfig',
'django_keycloak.apps.KeycloakAppConfig',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -51,6 +52,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django_keycloak.middleware.BaseKeycloakMiddleware',
] ]
ROOT_URLCONF = 'website.urls' ROOT_URLCONF = 'website.urls'
@ -134,3 +136,9 @@ REST_FRAMEWORK = {
'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.SessionAuthentication',
] ]
} }
AUTHENTICATION_BACKENDS = [
'django_keycloak.auth.backends.KeycloakAuthorizationCodeBackend',
]
LOGIN_URL = 'keycloak_login'

View File

@ -13,6 +13,7 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path 1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django import urls
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
@ -23,4 +24,5 @@ urlpatterns = [
urlpatterns += [ urlpatterns += [
path('api-auth/', include('rest_framework.urls')), path('api-auth/', include('rest_framework.urls')),
path(r'^keycloak/', include('django_keycloak.urls')),
] ]