Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #52 from drjova/JWT
Browse files Browse the repository at this point in the history
global: enable JWT token authentication
  • Loading branch information
drjova authored Jul 9, 2024
2 parents 579183b + 4f2cbb2 commit 1606a32
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"django_prometheus",
"django_opensearch_dsl",
"django_elasticsearch_dsl_drf",
"rest_framework_simplejwt",
]

LOCAL_APPS = ["backoffice.users", "backoffice.workflows", "backoffice.management"]
Expand Down Expand Up @@ -341,6 +342,7 @@
"DEFAULT_AUTHENTICATION_CLASSES": (
"rest_framework.authentication.SessionAuthentication",
"rest_framework.authentication.TokenAuthentication",
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
"DEFAULT_PERMISSION_CLASSES": ("backoffice.management.permissions.IsAdminOrCuratorUser",),
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
Expand Down
6 changes: 6 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from django.views.generic import TemplateView
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
from rest_framework.authtoken.views import obtain_auth_token
from rest_framework_simplejwt.views import (
TokenObtainPairView,
TokenRefreshView,
)

from backoffice.workflows.admin import workflow_admin_site

Expand Down Expand Up @@ -38,6 +42,8 @@
SpectacularSwaggerView.as_view(url_name="api-schema"),
name="api-docs",
),
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
]

if settings.DEBUG:
Expand Down
29 changes: 26 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ elasticsearch = "6.8.2"
django-elasticsearch-dsl-drf = {git = "https://github.com/cern-sis/django-elasticsearch-dsl-drf.git", rev = "opensearch"}
opensearch-dsl = "^2.1.0"
opensearch-py = "2.6.0"
djangorestframework-simplejwt = "^5.3.1"

[tool.poetry.dev-dependencies]
factory-boy = "3.3.0"
Expand Down

0 comments on commit 1606a32

Please sign in to comment.