cors
This commit is contained in:
parent
456b5cdf3c
commit
f079d90d0e
Binary file not shown.
@ -42,6 +42,7 @@ INSTALLED_APPS = [
|
||||
'tapdata',
|
||||
'stacking',
|
||||
'rest_framework',
|
||||
'rest_framework_simplejwt',
|
||||
'corsheaders',
|
||||
]
|
||||
|
||||
@ -57,14 +58,33 @@ MIDDLEWARE = [
|
||||
|
||||
]
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_PERMISSION_CLASSES':[
|
||||
'rest_framework.permissions.AllowAny'
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
||||
],
|
||||
}
|
||||
from datetime import timedelta
|
||||
SIMPLE_JWT = {
|
||||
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5),
|
||||
'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
|
||||
'ROTATE_REFRESH_TOKENS': True,
|
||||
'BLACKLIST_AFTER_ROTATION': True,
|
||||
'ALGORITHM': 'HS256',
|
||||
'SIGNING_KEY': SECRET_KEY,
|
||||
'VERIFYING_KEY': None,
|
||||
'AUTH_HEADER_TYPES': ('Bearer',),
|
||||
'USER_ID_FIELD': 'id',
|
||||
'USER_ID_CLAIM': 'user_id',
|
||||
'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
|
||||
}
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
'https://pizzafresca.ru', #TODOPROJECT CHANGE IT
|
||||
'https://pizzafresca.ru',
|
||||
'http://localhost:3000',
|
||||
|
||||
'http://localhost:5173',
|
||||
#TODOPROJECT CHANGE IT
|
||||
|
||||
# другие источники, если необходимо
|
||||
]
|
||||
@ -108,10 +128,10 @@ import os
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'mydatabase',
|
||||
'USER': 'myuser',
|
||||
'PASSWORD': 'mypassword',
|
||||
'HOST': 'db',
|
||||
'NAME': 'erkesh_mal',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': 'swydk',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
|
BIN
main/__pycache__/permissions.cpython-310.pyc
Normal file
BIN
main/__pycache__/permissions.cpython-310.pyc
Normal file
Binary file not shown.
Binary file not shown.
10
main/permissions.py
Normal file
10
main/permissions.py
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
from rest_framework.permissions import BasePermission
|
||||
|
||||
class IsAdminUser(BasePermission):
|
||||
"""
|
||||
Разрешение, которое позволяет доступ только для администраторов.
|
||||
"""
|
||||
|
||||
def has_permission(self, request, view):
|
||||
return request.user and request.user.is_staff
|
@ -4,7 +4,7 @@ from rest_framework.routers import DefaultRouter
|
||||
from users.views import UserViewSet, DailyRewardViewSet, DailyRewardsListViewSet, BalanceViewSet, LevelsViewSet
|
||||
from tapdata.views import FarmingViewSet
|
||||
from stacking.views import UserStakeViewSet, StakeViewSet
|
||||
|
||||
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
|
||||
|
||||
""" from tapdata.views import TapDataViewSet
|
||||
from stacking.views import UserStakeViewSet, StakeViewSet """
|
||||
@ -28,4 +28,6 @@ router.register(r'stake', StakeViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
path('api/', include(router.urls)),
|
||||
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
||||
path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
||||
]
|
||||
|
@ -1,3 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
|
||||
# Create your views here.
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user