diff --git a/freekake_api/freekake_api/settings.py b/freekake_api/freekake_api/settings.py index d5c7ef0..50e5240 100644 --- a/freekake_api/freekake_api/settings.py +++ b/freekake_api/freekake_api/settings.py @@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/5.1/ref/settings/ from pathlib import Path from decouple import config, Csv +from datetime import timedelta import os # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -159,18 +160,18 @@ REST_FRAMEWORK = { 'DEFAULT_FILTER_BACKENDS': [ 'django_filters.rest_framework.DjangoFilterBackend' ], - # 'DEFAULT_AUTHENTICATION_CLASSES': ( - # 'rest_framework.authentication.BasicAuthentication', - # 'rest_framework.authentication.SessionAuthentication', - # 'oauth2_provider.contrib.rest_framework.OAuth2Authentication', - # ), - # 'DEFAULT_PERMISSION_CLASSES': ( - # 'rest_framework.permissions.IsAuthenticated', - # ) + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.BasicAuthentication', + 'rest_framework.authentication.SessionAuthentication', + # 'rest_framework_simplejwt.authentication.JWTAuthentication', + 'oauth2_provider.contrib.rest_framework.OAuth2Authentication', + ), + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.IsAuthenticated', + ) } OAUTH2_PROVIDER = { - # this is the list of available scopes 'SCOPES': {'read': 'Read scope', 'write': 'Write scope', 'groups': 'Access to your groups'} } @@ -192,3 +193,20 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' DATA_UPLOAD_MAX_MEMORY_SIZE = 2 * 1024 * 1024 # 5MB + +SIMPLE_JWT = { + 'AUTH_HEADER_TYPES': ('JWT',), +} + +DJOSER = { + 'TOKEN_MODEL': None, +} + +SIMPLE_JWT = { + "ACCESS_TOKEN_LIFETIME": timedelta(minutes=5), + "REFRESH_TOKEN_LIFETIME": timedelta(days=1), + + "AUDIENCE": 'freekake_api', + "ISSUER": 'freekake_api', +} + diff --git a/freekake_api/freekake_api/urls.py b/freekake_api/freekake_api/urls.py index 2b02c09..0627513 100644 --- a/freekake_api/freekake_api/urls.py +++ b/freekake_api/freekake_api/urls.py @@ -25,6 +25,7 @@ urlpatterns = [ path('admin/', admin.site.urls), path('oauth/', include(oauth2_urls)), path('auth/', include('djoser.urls')), + # path('auth/', include('djoser.urls.jwt')), path('core/', include('core.urls')), path('content/', include('content.urls')),