优化代码,修改cors逻辑

dependabot/npm_and_yarn/fir_admin/url-parse-1.5.10
MMXX 3 years ago
parent 878183dbce
commit 32ca967d07
  1. 10
      fir_client/src/components/apps/FirAppInfossecurity.vue
  2. 13
      fir_ser/admin/utils.py
  3. 9
      fir_ser/admin/views/app.py
  4. 9
      fir_ser/admin/views/report.py
  5. 9
      fir_ser/admin/views/storage.py
  6. 8
      fir_ser/admin/views/supersign.py
  7. 22
      fir_ser/api/utils/middlewares.py
  8. 8
      fir_ser/api/utils/modelutils.py
  9. 9
      fir_ser/api/views/advert.py
  10. 11
      fir_ser/api/views/domain.py
  11. 17
      fir_ser/api/views/order.py
  12. 10
      fir_ser/api/views/supersign.py
  13. 9
      fir_ser/api/views/thirdlogin.py
  14. 30
      fir_ser/fir_ser/settings.py
  15. 3
      fir_ser/requirements.txt

@ -324,11 +324,11 @@ export default {
this.currentapp = this.$store.state.currentapp;
this.set_default_flag();
this.orgcurrentapp = deepCopy(this.currentapp);
if (!this.currentapp.domain_name || this.currentapp.domain_name.length < 3) {
if (this.$store.state.userinfo.domain_name && this.$store.state.userinfo.domain_name.length > 3) {
this.defualt_dtitle = this.$store.state.userinfo.domain_name;
}
}
// if (!this.currentapp.domain_name || this.currentapp.domain_name.length < 3) {
// if (this.$store.state.userinfo.domain_name && this.$store.state.userinfo.domain_name.length > 3) {
// this.defualt_dtitle = this.$store.state.userinfo.domain_name;
// }
// }
this.setbuttondefault(this.currentapp);
}
},

@ -0,0 +1,13 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# project: 1月
# author: NinEveN
# date: 2022/1/6
from rest_framework.pagination import PageNumberPagination
class AppsPageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制

@ -6,10 +6,10 @@
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from admin.utils import AppsPageNumber
from api.base_views import app_delete
from api.models import AppReleaseInfo, Apps
from api.utils.TokenManager import verify_token
@ -22,13 +22,6 @@ from common.base.baseutils import get_dict_from_filter_fields
logger = logging.getLogger(__name__)
class AppsPageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class AppInfoView(APIView):
authentication_classes = [AdminTokenAuthentication, ]

@ -6,10 +6,10 @@
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from admin.utils import AppsPageNumber
from api.models import AppReportInfo
from api.utils.auth import AdminTokenAuthentication
from api.utils.response import BaseResponse
@ -19,13 +19,6 @@ from common.base.baseutils import get_dict_from_filter_fields
logger = logging.getLogger(__name__)
class AppsPageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class AdminReportView(APIView):
authentication_classes = [AdminTokenAuthentication, ]

@ -6,10 +6,10 @@
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from admin.utils import AppsPageNumber
from api.base_views import storage_change
from api.models import UserInfo, AppStorage
from api.utils.auth import AdminTokenAuthentication
@ -21,13 +21,6 @@ from common.base.baseutils import get_dict_from_filter_fields
logger = logging.getLogger(__name__)
class AppsPageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class StorageInfoView(APIView):
authentication_classes = [AdminTokenAuthentication, ]

@ -10,6 +10,7 @@ from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from admin.utils import AppsPageNumber
from api.models import APPSuperSignUsedInfo, AppIOSDeveloperInfo, IosDeveloperPublicPoolBill
from api.utils.auth import AdminTokenAuthentication
from api.utils.modelutils import get_user_public_used_sign_num, get_user_public_sign_num, get_user_obj_from_epu
@ -21,13 +22,6 @@ from common.base.baseutils import get_dict_from_filter_fields, get_real_ip_addre
logger = logging.getLogger(__name__)
class AppsPageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class DeveloperInfoView(APIView):
authentication_classes = [AdminTokenAuthentication, ]

@ -1,22 +0,0 @@
import logging
from django.utils.deprecation import MiddlewareMixin
logger = logging.getLogger(__name__)
class CorsMiddleWare(MiddlewareMixin):
def process_response(self, request, response):
if request.method == "OPTIONS":
response["Access-Control-Allow-Methods"] = "GET,POST,DELETE,PUT"
response["Access-Control-Allow-Headers"] = "Content-Type,AUTHORIZATION,x-token"
try:
response["Access-Control-Allow-Origin"] = request.META.get("HTTP_ORIGIN")
response["Access-Control-Allow-Credentials"] = 'true'
# response["Cache-Control"] = "no-cache"
except Exception as e:
logger.error(e)
return response

@ -10,6 +10,7 @@ import random
from urllib.parse import urljoin
from django.db.models import Count, Sum, Q
from rest_framework.pagination import PageNumberPagination
from api.models import AppReleaseInfo, UserDomainInfo, DomainCnameInfo, UserAdDisplayInfo, RemoteClientInfo, \
AppIOSDeveloperInfo, IosDeveloperPublicPoolBill, APPToDeveloper, UserInfo, UDIDsyncDeveloper
@ -253,3 +254,10 @@ def update_or_create_developer_udid_info(device_obj, developer_obj):
"status": True if device_obj.status == 'ENABLED' else False
}
return UDIDsyncDeveloper.objects.update_or_create(developerid=developer_obj, udid=device_obj.udid, defaults=device)
class PageNumber(PageNumberPagination):
page_size = 10 # 每页显示多少条
page_size_query_param = 'size' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制

@ -5,12 +5,12 @@
# date: 2021/10/14
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from api.models import UserAdDisplayInfo
from api.utils.auth import ExpiringTokenAuthentication, UserAdInfoPermission
from api.utils.modelutils import PageNumber
from api.utils.response import BaseResponse
from api.utils.serializer import UserAdInfoSerializer
from api.utils.storage.caches import reset_short_response_cache
@ -19,13 +19,6 @@ from api.utils.storage.storage import Storage
logger = logging.getLogger(__name__)
class PageNumber(PageNumberPagination):
page_size = 10 # 每页显示多少条
page_size_query_param = 'size' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class UserAdInfoView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
permission_classes = [UserAdInfoPermission, ]

@ -5,13 +5,12 @@
# date: 2021/3/29
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from api.models import UserDomainInfo, Apps
from api.utils.auth import ExpiringTokenAuthentication
from api.utils.modelutils import get_user_domain_name, get_min_default_domain_cname_obj
from api.utils.modelutils import get_user_domain_name, get_min_default_domain_cname_obj, PageNumber
from api.utils.response import BaseResponse
from api.utils.serializer import DomainNameSerializer
from api.utils.storage.caches import del_cache_response_by_short, reset_app_wx_easy_type
@ -122,6 +121,7 @@ class DomainCnameView(APIView):
if user_domain_obj:
res.data = {'cname_domain': user_domain_obj.cname_id.domain_record}
else:
kwargs.pop('domain_name')
UserDomainInfo.objects.filter(**kwargs, is_enable=False).delete()
add_new_domain_info(res, request, domain_name, domain_type)
else:
@ -197,13 +197,6 @@ class DomainCnameView(APIView):
return Response(res.dict)
class PageNumber(PageNumberPagination):
page_size = 10 # 每页显示多少条
page_size_query_param = 'size' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class DomainInfoView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]

@ -6,12 +6,12 @@
import logging
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from api.models import Price, Order
from api.utils.auth import ExpiringTokenAuthentication
from api.utils.modelutils import PageNumber
from api.utils.pay.util import get_pay_obj_form_name, get_enable_pay_choices, get_payment_type
from api.utils.response import BaseResponse
from api.utils.serializer import PriceSerializer, OrdersSerializer
@ -21,13 +21,6 @@ from common.base.baseutils import get_order_num, get_choices_dict
logger = logging.getLogger(__name__)
class PageNumber(PageNumberPagination):
page_size = 10 # 每页显示多少条
page_size_query_param = 'size' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class OrderView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
@ -134,14 +127,6 @@ class PriceView(APIView):
res.pay_choices = get_enable_pay_choices()
return Response(res.dict)
def delete(self, request):
res = BaseResponse()
return Response(res.dict)
def put(self, request):
res = BaseResponse()
return Response(res.dict)
class PaySuccess(APIView):

@ -9,7 +9,6 @@ import logging
from django.db.models import Count, Q, Sum
from django.http.response import FileResponse
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
@ -17,7 +16,7 @@ from api.models import AppIOSDeveloperInfo, APPSuperSignUsedInfo, AppUDID, IosDe
UDIDsyncDeveloper, AppleDeveloperToAppUse, Apps, DeveloperAppID, APPToDeveloper, DeveloperDevicesID
from api.utils.app.supersignutils import IosUtils
from api.utils.auth import ExpiringTokenAuthentication, SuperSignPermission
from api.utils.modelutils import get_user_public_used_sign_num, get_user_public_sign_num
from api.utils.modelutils import get_user_public_used_sign_num, get_user_public_sign_num, PageNumber
from api.utils.response import BaseResponse
from api.utils.serializer import DeveloperSerializer, SuperSignUsedSerializer, DeviceUDIDSerializer, BillInfoSerializer, \
DeveloperDeviceSerializer, AppleDeveloperToAppUseSerializer, AppleDeveloperToAppUseAppsSerializer
@ -30,13 +29,6 @@ from fir_ser.settings import DEVELOPER_USE_STATUS, DEVELOPER_DISABLED_STATUS
logger = logging.getLogger(__name__)
class PageNumber(PageNumberPagination):
page_size = 10 # 每页显示多少条
page_size_query_param = 'size' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class DeveloperView(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]
permission_classes = [SuperSignPermission, ]

@ -7,13 +7,13 @@ import logging
import random
from django.http.response import HttpResponse
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework_xml.parsers import XMLParser
from api.models import ThirdWeChatUserInfo, UserInfo, UserCertificationInfo
from api.utils.auth import ExpiringTokenAuthentication
from api.utils.modelutils import PageNumber
from api.utils.mp.chat import reply, receive
from api.utils.mp.wechat import check_signature, WxMsgCrypt, get_userinfo_from_openid, WxTemplateMsg
from api.utils.response import BaseResponse
@ -221,13 +221,6 @@ class ValidWxChatToken(APIView):
return HttpResponse("success")
class PageNumber(PageNumberPagination):
page_size = 10 # 每页显示多少条
page_size_query_param = 'size' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class ThirdWxAccount(APIView):
authentication_classes = [ExpiringTokenAuthentication, ]

@ -44,17 +44,18 @@ INSTALLED_APPS = [
'captcha',
'django_celery_beat',
'django_celery_results',
'corsheaders',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'api.utils.middlewares.CorsMiddleWare'
]
ROOT_URLCONF = 'fir_ser.urls'
@ -201,6 +202,33 @@ REST_FRAMEWORK_EXTENSIONS = {
# 取消自动加斜杠
APPEND_SLASH = False
# https://pypi.org/project/django-cors-headers/
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_METHODS = (
'DELETE',
'GET',
'OPTIONS',
'POST',
'PUT',
)
CORS_ALLOW_HEADERS = (
'XMLHttpRequest',
"accept",
"accept-encoding",
"authorization",
"content-type",
"dnt",
"origin",
"user-agent",
"x-csrftoken",
"x-requested-with",
"x-token"
)
# geetest 配置信息
GEETEST_ID = BASECONF.GEETEST_ID
GEETEST_KEY = BASECONF.GEETEST_KEY

@ -20,4 +20,5 @@ python-daemon==2.2.3
psutil==5.6.6
flower==1.0.0
django-proxy==1.2.1
uWSGI==2.0.20
uWSGI==2.0.20
django-cors-headers==3.10.1
Loading…
Cancel
Save