Skip to content

Commit 9b5d9ec

Browse files
feat: enable session authentication and support cross-origin credentials
- Added SessionAuthentication alongside JWTAuthentication to support session-based features - Set CORS_ALLOW_CREDENTIALS = True to allow cookies in cross-origin requests (needed for session handling)
1 parent fe046b6 commit 9b5d9ec

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

ecommerce_api/settings/base.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
"""
2-
Django settings for ecommerce_api project.
3-
4-
Generated by 'django-admin startproject' using Django 5.2.
5-
6-
For more information on this file, see
7-
https://docs.djangoproject.com/en/5.2/topics/settings/
8-
9-
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/5.2/ref/settings/
11-
"""
12-
131
from datetime import timedelta
142
from pathlib import Path
153

@@ -31,6 +19,8 @@
3119
ALLOWED_HOSTS = []
3220

3321
CORS_ALLOW_ALL_ORIGINS = True
22+
CORS_ALLOW_CREDENTIALS = True
23+
3424
# Application definition
3525
# ╭──────────────────────────────────────────────────────────╮
3626
# │ Application Configuration │
@@ -180,7 +170,7 @@
180170
REST_FRAMEWORK = {
181171
'DEFAULT_AUTHENTICATION_CLASSES': (
182172
'rest_framework_simplejwt.authentication.JWTAuthentication',
183-
# 'rest_framework.authentication.SessionAuthentication',
173+
'rest_framework.authentication.SessionAuthentication',
184174
),
185175
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
186176
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
@@ -400,7 +390,7 @@
400390
'type': 'apiKey',
401391
'name': 'Authorization',
402392
'in': 'header',
403-
'description': "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
393+
'description': "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}",
404394
}
405395
},
406396
'USE_SESSION_AUTH': False,

0 commit comments

Comments
 (0)