From a9820ca7f30bb578d2790eef70dcc3551b64999e Mon Sep 17 00:00:00 2001 From: zcx Date: Tue, 28 May 2024 20:41:07 +0800 Subject: [PATCH] second commit --- auth/.DS_Store | Bin 6148 -> 0 bytes auth/MyRateThrottle.py | 5 -- auth/__init__.py | 0 .../MyRateThrottle.cpython-312.pyc | Bin 470 -> 0 bytes .../__pycache__/MyRateThrottle.cpython-38.pyc | Bin 424 -> 0 bytes auth/__pycache__/__init__.cpython-312.pyc | Bin 167 -> 0 bytes auth/__pycache__/__init__.cpython-38.pyc | Bin 144 -> 0 bytes .../authentication.cpython-312.pyc | Bin 2199 -> 0 bytes .../__pycache__/authentication.cpython-38.pyc | Bin 1457 -> 0 bytes auth/authentication.py | 45 ------------------ permission/.DS_Store | Bin 6148 -> 0 bytes permission/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 173 -> 0 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 150 -> 0 bytes .../__pycache__/permission.cpython-312.pyc | Bin 773 -> 0 bytes .../__pycache__/permission.cpython-38.pyc | Bin 527 -> 0 bytes permission/permission.py | 12 ----- 17 files changed, 62 deletions(-) delete mode 100644 auth/.DS_Store delete mode 100644 auth/MyRateThrottle.py delete mode 100644 auth/__init__.py delete mode 100644 auth/__pycache__/MyRateThrottle.cpython-312.pyc delete mode 100644 auth/__pycache__/MyRateThrottle.cpython-38.pyc delete mode 100644 auth/__pycache__/__init__.cpython-312.pyc delete mode 100644 auth/__pycache__/__init__.cpython-38.pyc delete mode 100644 auth/__pycache__/authentication.cpython-312.pyc delete mode 100644 auth/__pycache__/authentication.cpython-38.pyc delete mode 100644 auth/authentication.py delete mode 100644 permission/.DS_Store delete mode 100644 permission/__init__.py delete mode 100644 permission/__pycache__/__init__.cpython-312.pyc delete mode 100644 permission/__pycache__/__init__.cpython-38.pyc delete mode 100644 permission/__pycache__/permission.cpython-312.pyc delete mode 100644 permission/__pycache__/permission.cpython-38.pyc delete mode 100644 permission/permission.py diff --git a/auth/.DS_Store b/auth/.DS_Store deleted file mode 100644 index a292f56e49e07b1b584c4550f1aadb55b0d12f63..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJ8r`;3?&;60kUMws4L_KLXe&y2XONPG8k}yqC+=NIaiL>$IoK8-JB(O1gIxb zd=m5q(-aZieP6aBYY|z(4drgb)NJ2;Vs9ByARK3$tC`N@F;svGyp96)eJF6lnm7ddrvrnx0Kf)e zH_W}402T`XYvK@y2uy*H-`E;s5miV-i z{fa;WU}-;1=3A0Qsl_GnX+=PXm**E{>ylcR&#CLW@ j{6H=v5EqLAi4V+-jEr{~%)YQOGOAw?RsG5Uq`}$%mBxD) diff --git a/auth/__pycache__/MyRateThrottle.cpython-38.pyc b/auth/__pycache__/MyRateThrottle.cpython-38.pyc deleted file mode 100644 index 0ae2d6b891c53ea0410845550a1909bf46e9d49c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 424 zcmY*Vu};G<5Vhk}3RPP%u&}XaDH97qs1;N&K#|h0M3F43HY6f(g6)9P6;{51nGfoc zm5Ec z5%`5f4tH0`AAErd`MBAg%R&ash%ixwF_~Cfq8|=`8KmBWB2a`m0u#)g6i0*;Fms#9 zb=~)9Tn4V2!O>x!$|dj~rIO`>(q>3$Uhpcj{fN@Xie()WO~T9ICJe6@G?<5r)dx}@ zeAt%nv-9JaWocbW`dp|7U9z=^%i1J`q&g|eSPS(eRGinWEMr!gB>q3qw5$~YJ9{N< uH}Y_cmp+O1mC%OXDHzb2Pfd4;RNgDAY;}LLblnaRjd#+ma*BUlN8|@3_G)AR diff --git a/auth/__pycache__/__init__.cpython-312.pyc b/auth/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 9de525dc88efeea03a0d1e754b35ac5843103b95..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 167 zcmX@j%ge<81lQ{W(?IlN5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!a&xhYDX1*T$j^%} z&d4v&%}p#WNiD)ARGeB=29(LIOe`pfNh~eNh>4HS%*!l^kJl@x{Ka9Do1apelWJGQ V3N)4xh>JmtkIamWj77{q764CLEK&df diff --git a/auth/__pycache__/__init__.cpython-38.pyc b/auth/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 41311d22b2b93f1faa371167e97e2f8358bd3316..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 144 zcmWIL<>g`kf(fqaDIoeWh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6w%#VV$tC_gJT zxuiIzpt2+*KQF#GBflV~IJKxOwJ0XHGO?f_Cb6_6BPKpRGcU6wK3=b&@)n0pZhlH> NPO2TqxX(b$003-PB5eQw diff --git a/auth/__pycache__/authentication.cpython-312.pyc b/auth/__pycache__/authentication.cpython-312.pyc deleted file mode 100644 index 7fcd63d3985cb378d9df0679446f42cfd76abb32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2199 zcmb`IO>7%Q6o6;{Y{yxr8^?Cr;DCz>!D-1K6cDtPoZ4whQ->etVntd^c0=s=FSF}{ zqeP@A5;<_mDN-7VNC+t*NTerFFL39w#;IJ5+!LWRx1fYePt5Fk{Zkc{O3dNSoA=)Q z?DPAce|0$Q0FUzL?@!NK0Qj9O%)wQaqbOF^fCMBe1=3WEqKHnX=rj{!be&1DX)eZ5 zfCg89#4ZDglbIdH*dMd#RtvUT8?4rXEzoj6LIM=B%b!ijIW>{ZD0t-@jw^C7ug=IB zH8B+@W^83A6d6t#XBv{KE{>d7SpzbNQ4)yJ615CsOo0wC$P<*(iA*#*D`&`g=4n%O z!!az@$y1NK_`Ef+KqVWTrkbpNjJYPWMD0{xut=+BvT$M+=y~ileH2h}VvUisnOc2L zw$^o1TcE#Z%>9c@3s|6`Pj%G1HJ`-Jz5;;aTwo;jG&4Z=&hd+P0ZAa|&a5RXR zPh=HwIhe?(kR%ydvmYnrDOEw1=|oDEA!1T;2C*=kk|Ft(kgK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PCje@7yHwa~R>W_G4&$%C8zW!YQDzV-rTcWQVLvaQLK9Pgn!M2@- zsc;*i!_-4OJjA2GJi2_gdhp%vr$e3qw}GI@tu%edsF>z%-%4;?1OC1w{BsiuU2L-;_#q A)&Kwi diff --git a/auth/authentication.py b/auth/authentication.py deleted file mode 100644 index 38f7c91..0000000 --- a/auth/authentication.py +++ /dev/null @@ -1,45 +0,0 @@ -from rest_framework import exceptions -from rest_framework.authentication import BaseAuthentication - -from myapp.models import User - - -# 后台接口认证 -class AdminTokenAuthtication(BaseAuthentication): - def authenticate(self, request): - adminToken = request.META.get("HTTP_ADMINTOKEN") - print("检查adminToken==>" + adminToken) - users = User.objects.filter(admin_token=adminToken) - """ - 判定条件: - 1. 传了adminToken - 2. 查到了该帐号 - 3. 该帐号是管理员或演示帐号 - """ - if not adminToken or len(users) == 0 or users[0].role == '2': - raise exceptions.AuthenticationFailed("AUTH_FAIL_END") - else: - print('adminToken验证通过') - - -# 前台接口认证 -class TokenAuthtication(BaseAuthentication): - def authenticate(self, request): - token = request.META.get("HTTP_TOKEN", "") - if token is not None: - print("检查token==>" + token) - users = User.objects.filter(token=token) - # print(users) - """ - 判定条件: - 1. 传了token - 2. 查到了该帐号 - 3. 该帐号是普通用户 - """ - if not token or len(users) == 0 or (users[0].role in ['1', '3']): - raise exceptions.AuthenticationFailed("AUTH_FAIL_FRONT") - else: - print('token验证通过') - else: - print("检查token==>token 为空") - raise exceptions.AuthenticationFailed("AUTH_FAIL_FRONT") diff --git a/permission/.DS_Store b/permission/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0DX1*T$j^%} z&d4v&%}p#WNiD)ARGeB=29(LIOe`pfDM&5K%`7g?%+HI7kI&4@EQycTE2#X%VUwGm bQks)$SHuc5oDqnNL5z>gjEsy$%s>_Znk+8w diff --git a/permission/__pycache__/__init__.cpython-38.pyc b/permission/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 2e837b98f806304c6b349beb9f6011e5e882c265..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 150 zcmWIL<>g`kf(fqaDIoeWh(HF6K#l_t7qb9~6oz01O-8?!3`HPe1o6w-#VV$tC_gJT zxuiIzpt2+*KQF#GBflV~IJKxOwJ0XHGO?f_rXaN_H?z1nGe0jTK0Y%qvm`!Vub}c4 ThfQvNN@-529mvqnK+FIDU1B8) diff --git a/permission/__pycache__/permission.cpython-312.pyc b/permission/__pycache__/permission.cpython-312.pyc deleted file mode 100644 index bec244ee8208dbacc170c5a37c6052fa4c16519e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 773 zcmZuv&ubGw6rS1L{4m*&tgTwHl2#PV!CtCJ#S{XGXlIpYpz4W>#FV| zOn4ocM8KAgNXW*j>1G5H!RTHUIWCF$vt%}kgsSuo93uFE2{%P;znH(YYJ2X6WtN-` z%RXn69oqGODZ2YUtr%X}wpVS04b^c}%lr$@*d9r$P97Onj{PIMbUaQcv1!h2>gu2; zO|&PUPj;p0ZE3o5YIa9DUtj2pspev1u`8yx#q{fij+ovNFV+kFNNnrE(}%6xlSjSe zcx$=wU`y!5lg+ut+)MsT{6t@rI)_hx70>j>j`iZH0UZE}8J>v#8D|VjLAvA1=AYsX nz(*(pk5RWDy-dqh9nIqjx@0fPNl^EjhY;?9lY?*+NvlPIJV$^|~bmtMFbQW4>xR;U4~?xnI6mG08ovAyo@8Yz-CNaxKf*ElBtTD{w*1bJ2nf zKEf(+VH;e4oXolVTB=*!5+2;Rp8)nC#Qg!3;NdljQAu67TQLk~goX zGuq(Zu`IJ{?({-c#xH{Kw0S`B*N>aupTFOIyS}^nIv$UAl2_3H#r`yzAU{>kc%|6a z?{anGEcV`Kg;NH3p(+$c7Yf7LWR;5q_KiAklyx}lW+i?Uh7BpVD17+B%tK=PJC2{F zwb318S})z1uIBbk*D3XUP$n&x$90|7%9NS4nXcB-?RtrunT=JcCti@ht3RdnQW%Wj vK4Abuf&lY~{$>%!QOCGlYN-m_De6kyHfwH++Hvrl+L}V`_#;`be#HL)=ZA^6 diff --git a/permission/permission.py b/permission/permission.py deleted file mode 100644 index e25a1e8..0000000 --- a/permission/permission.py +++ /dev/null @@ -1,12 +0,0 @@ -from myapp.models import User - - -def isDemoAdminUser(request): - adminToken = request.META.get("HTTP_ADMINTOKEN") - users = User.objects.filter(admin_token=adminToken) - if len(users) > 0: - user = users[0] - if user.role == '3': # (角色3)表示演示帐号 - print('演示帐号===>') - return True - return False