django-restit 4.2.49__py3-none-any.whl → 4.2.51__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- auditlog/middleware.py +10 -3
- {django_restit-4.2.49.dist-info → django_restit-4.2.51.dist-info}/METADATA +1 -1
- {django_restit-4.2.49.dist-info → django_restit-4.2.51.dist-info}/RECORD +7 -7
- rest/__init__.py +1 -1
- rest/crypto/aes.py +31 -7
- {django_restit-4.2.49.dist-info → django_restit-4.2.51.dist-info}/LICENSE.md +0 -0
- {django_restit-4.2.49.dist-info → django_restit-4.2.51.dist-info}/WHEEL +0 -0
auditlog/middleware.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
from rest import settings
|
2
|
+
from rest import helpers as rh
|
2
3
|
from .models import PersistentLog
|
3
4
|
|
4
5
|
DEBUG_REST_ALL = settings.get("DEBUG_REST_ALL", False)
|
@@ -10,19 +11,23 @@ if not LOG_REST_PREFIX.startswith("/"):
|
|
10
11
|
|
11
12
|
|
12
13
|
def checkRestDebug(request):
|
14
|
+
if checkRestIgnore(request):
|
15
|
+
return False
|
13
16
|
if DEBUG_REST_ALL:
|
14
17
|
return True
|
15
18
|
for ep in DEBUG_REST_END_POINTS:
|
16
19
|
if request.path.startswith(ep):
|
17
|
-
return
|
20
|
+
return True
|
18
21
|
return False
|
19
22
|
|
20
23
|
|
21
24
|
def checkRestIgnore(request):
|
22
25
|
for ep in IGNORE_REST_END_POINTS:
|
23
26
|
if isinstance(ep, tuple):
|
24
|
-
method,
|
25
|
-
|
27
|
+
method, epath = ep
|
28
|
+
if request.method == method and request.path.startswith(epath):
|
29
|
+
return True
|
30
|
+
rh.debug("checkRestIgnore", f"{ep} vs {request.path}")
|
26
31
|
if request.path.startswith(ep):
|
27
32
|
return True
|
28
33
|
return False
|
@@ -40,8 +45,10 @@ class LogRequest(object):
|
|
40
45
|
def process_request(self, request):
|
41
46
|
# LogRequest.last_request = request
|
42
47
|
request.rest_debug = False
|
48
|
+
rh.debug("LogRequest.process_request", request.path, DEBUG_REST_ALL)
|
43
49
|
if request.path.startswith(LOG_REST_PREFIX) or request.path.startswith("/rpc/"):
|
44
50
|
request.rest_debug = checkRestDebug(request)
|
51
|
+
rh.debug("checkRestDebug", request.rest_debug, IGNORE_REST_END_POINTS)
|
45
52
|
if request.rest_debug:
|
46
53
|
request.DATA.log()
|
47
54
|
response = self.get_response(request)
|
@@ -58,7 +58,7 @@ auditlog/README,sha256=q4DXhdz5CuMyuxYISHXzhlHnIkRJlojwOMchLzW2qOI,520
|
|
58
58
|
auditlog/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
59
59
|
auditlog/admin.py,sha256=-q7fstdFjNeDFfbwdrxVqy0WGKxMpBwrsM7AyG1p80g,1006
|
60
60
|
auditlog/decorators.py,sha256=ZoIv0fhZjxtMEV15NcKijW4xPF5UEScPna60zB3TxZo,6553
|
61
|
-
auditlog/middleware.py,sha256=
|
61
|
+
auditlog/middleware.py,sha256=SSzqqSg_5l6x8LEvawt_RpIvNwKaIeMjxjNJ_UMkICM,1826
|
62
62
|
auditlog/migrations/0001_initial.py,sha256=X171gKQZIaTO9FGNG1yKTjGSZS0ZjZj5gvimF9-_kks,3309
|
63
63
|
auditlog/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
64
64
|
auditlog/models.py,sha256=6CyWMRNvqCYoyiXE9_qk41EJFjutwo6nfoP9KKYWiYw,16294
|
@@ -363,11 +363,11 @@ pushit/utils.py,sha256=IeTCGa-164nmB1jIsK1lu1O1QzUhS3BKfuXHGjCW-ck,2121
|
|
363
363
|
rest/.gitignore,sha256=TbEvWRMnAiajCTOdhiNrd9eeCAaIjRp9PRjE_VkMM5g,118
|
364
364
|
rest/README.md,sha256=V3ETc-cJu8PZIbKr9xSe_pA4JEUpC8Dhw4bQeVCDJPw,5460
|
365
365
|
rest/RemoteEvents.py,sha256=nL46U7AuxIrlw2JunphR1tsXyqi-ep_gD9CYGpYbNgE,72
|
366
|
-
rest/__init__.py,sha256=
|
366
|
+
rest/__init__.py,sha256=uoSQO22cfX2kuQ8uMpqYGrAX4PDy2Lvp_3n4797fgfk,121
|
367
367
|
rest/arc4.py,sha256=y644IbF1ec--e4cUJ3KEYsewTCITK0gmlwa5mJruFC0,1967
|
368
368
|
rest/cache.py,sha256=1Qg0rkaCJCaVP0-l5hZg2CIblTdeBSlj_0fP6vlKUpU,83
|
369
369
|
rest/crypto/__init__.py,sha256=Tl0U11rgj1eBYqd6OXJ2_XSdNLumW_JkBZnaJqI6Ldw,72
|
370
|
-
rest/crypto/aes.py,sha256=
|
370
|
+
rest/crypto/aes.py,sha256=NOVRBRSHCV-om68YpGySWWG-4kako3iEVjq8hxZWPUU,4372
|
371
371
|
rest/crypto/privpub.py,sha256=_FioylVcbMmDP80yPYjURmafEiDmEAMkskbc7WF10ac,4082
|
372
372
|
rest/crypto/util.py,sha256=agFN2OCPHC70tHNGWrMkkZX4Tt_Ty6imoKEMdTkZpKA,4514
|
373
373
|
rest/datem.py,sha256=CHWQXgNltXxtWg34Xio-nNG_2FC6X1RSN3LrCKz2TvU,9469
|
@@ -496,7 +496,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
|
|
496
496
|
ws4redis/settings.py,sha256=K0yBiLUuY81iDM4Yr-k8hbvjn5VVHu5zQhmMK8Dtz0s,1536
|
497
497
|
ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
|
498
498
|
ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
|
499
|
-
django_restit-4.2.
|
500
|
-
django_restit-4.2.
|
501
|
-
django_restit-4.2.
|
502
|
-
django_restit-4.2.
|
499
|
+
django_restit-4.2.51.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
|
500
|
+
django_restit-4.2.51.dist-info/METADATA,sha256=qolKiTHvTmfWLH7kIudyKPMtMg01aTX6ohPAjY-JZMs,7594
|
501
|
+
django_restit-4.2.51.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
502
|
+
django_restit-4.2.51.dist-info/RECORD,,
|
rest/__init__.py
CHANGED
rest/crypto/aes.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
from Crypto.Cipher import AES
|
2
2
|
from Crypto import Random
|
3
|
-
|
3
|
+
import hashlib
|
4
|
+
from hashlib import md5, sha256
|
4
5
|
|
5
6
|
import json
|
6
7
|
from . import util
|
@@ -10,29 +11,36 @@ DEFAULT_SALT = b"Salted__"
|
|
10
11
|
MD5V_SALT = b"__MD5V__"
|
11
12
|
SDKV_SALT = b"__SDKV__"
|
12
13
|
SDKV16_SALT = b"__SDKV16"
|
14
|
+
SHA256_SALT = b"SALTY__"
|
13
15
|
|
14
|
-
KNOWN_SALTS = [DEFAULT_SALT, SDKV_SALT, MD5V_SALT, SDKV16_SALT]
|
16
|
+
KNOWN_SALTS = [DEFAULT_SALT, SDKV_SALT, MD5V_SALT, SDKV16_SALT, SHA256_SALT]
|
15
17
|
|
16
18
|
DEFAULT_IV_GENERATOR = "md5"
|
17
19
|
|
18
|
-
# THIS USES AES/CBC/PKCS7Padding
|
19
20
|
|
20
|
-
def encrypt(key, data, random_size=128, ivgen=DEFAULT_IV_GENERATOR):
|
21
|
+
def encrypt(key, data, random_size=128, ivgen=DEFAULT_IV_GENERATOR, base64=True):
|
21
22
|
"""
|
22
23
|
encrypts @data with @key using AES
|
23
24
|
will pad data with random string of @random_size
|
24
25
|
this will keep it so the same data is never producing the same encryption
|
25
26
|
returns bytes as base64 string
|
27
|
+
|
28
|
+
HIS USES AES/CBC/PKCS7Padding
|
26
29
|
"""
|
27
30
|
if random_size > 0:
|
28
31
|
rdata = util.toBytes(data) + util.toBytes(util.randomString(random_size))
|
29
32
|
else:
|
30
33
|
rdata = data
|
34
|
+
if not base64:
|
35
|
+
return cbc_encrypt(key, rdata, ivgen, base64)
|
31
36
|
return util.toString(cbc_encrypt(key, rdata, ivgen))
|
32
37
|
|
33
38
|
|
34
|
-
def decrypt(key, edata, random_size=128, as_string=True):
|
35
|
-
|
39
|
+
def decrypt(key, edata, random_size=128, as_string=True, base64=True):
|
40
|
+
if base64:
|
41
|
+
encrypted = util.fromBase64(edata, False)
|
42
|
+
else:
|
43
|
+
encrypted = edata
|
36
44
|
data = cbc_decrypt(key, encrypted)
|
37
45
|
if random_size > 0:
|
38
46
|
data = data[:-1 * random_size]
|
@@ -41,7 +49,7 @@ def decrypt(key, edata, random_size=128, as_string=True):
|
|
41
49
|
return data
|
42
50
|
|
43
51
|
|
44
|
-
def cbc_encrypt(key, data, ivgen=DEFAULT_IV_GENERATOR):
|
52
|
+
def cbc_encrypt(key, data, ivgen=DEFAULT_IV_GENERATOR, base64=True):
|
45
53
|
if isinstance(data, dict) or isinstance(data, list):
|
46
54
|
data = json.dumps(data)
|
47
55
|
salt_prefix = getSaltPrefix(ivgen)
|
@@ -57,6 +65,8 @@ def cbc_encrypt(key, data, ivgen=DEFAULT_IV_GENERATOR):
|
|
57
65
|
key = key_iv[:32]
|
58
66
|
iv = key_iv[32:]
|
59
67
|
aes = AES.new(key, AES.MODE_CBC, iv)
|
68
|
+
if not base64:
|
69
|
+
return salt_prefix + salt + aes.encrypt(util.pad(data))
|
60
70
|
return util.toBase64(salt_prefix + salt + aes.encrypt(util.pad(data)))
|
61
71
|
|
62
72
|
|
@@ -82,6 +92,8 @@ def cbc_decrypt(key, encrypted):
|
|
82
92
|
def deterministric_key_iv(generator, data, salt, length=48):
|
83
93
|
if generator in [DEFAULT_SALT, MD5V_SALT, "md5"]:
|
84
94
|
return md5_deterministic_key_iv(data, salt, length)
|
95
|
+
elif generator == SHA256_SALT:
|
96
|
+
return sha256_deterministic_key_iv(data, salt, length)
|
85
97
|
return simple_deterministic_key_iv(data, salt, length)
|
86
98
|
|
87
99
|
|
@@ -105,6 +117,18 @@ def md5_deterministic_key_iv(data, salt, length=48):
|
|
105
117
|
return final_key[:length]
|
106
118
|
|
107
119
|
|
120
|
+
def sha256_deterministic_key_iv(data, salt, length=48):
|
121
|
+
# extended from https://gist.github.com/gsakkis/4546068
|
122
|
+
assert len(salt) == 8, len(salt)
|
123
|
+
data += salt
|
124
|
+
key = sha256(data).digest()
|
125
|
+
final_key = key
|
126
|
+
while len(final_key) < length:
|
127
|
+
key = sha256(key + data).digest()
|
128
|
+
final_key += key
|
129
|
+
return final_key[:length]
|
130
|
+
|
131
|
+
|
108
132
|
def simple_deterministic_key_iv(data, salt, length=48):
|
109
133
|
src = data + salt
|
110
134
|
src_len = len(src)
|
File without changes
|
File without changes
|