gomyck-tools 1.2.6__py3-none-any.whl → 1.2.7__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.
- ctools/token.py +9 -0
- {gomyck_tools-1.2.6.dist-info → gomyck_tools-1.2.7.dist-info}/METADATA +1 -1
- {gomyck_tools-1.2.6.dist-info → gomyck_tools-1.2.7.dist-info}/RECORD +5 -5
- {gomyck_tools-1.2.6.dist-info → gomyck_tools-1.2.7.dist-info}/WHEEL +0 -0
- {gomyck_tools-1.2.6.dist-info → gomyck_tools-1.2.7.dist-info}/top_level.txt +0 -0
ctools/token.py
CHANGED
@@ -5,9 +5,12 @@ __date__ = '2025/1/21 16:01'
|
|
5
5
|
|
6
6
|
import time
|
7
7
|
import jwt
|
8
|
+
from bottle import request
|
8
9
|
|
9
10
|
from ctools.dict_wrapper import DictWrapper
|
10
11
|
|
12
|
+
token_header = 'Authorization'
|
13
|
+
|
11
14
|
def gen_token(payload: {}, secret_key, expired: int=3600) -> str:
|
12
15
|
payload.update({'exp': time.time() + expired})
|
13
16
|
return jwt.encode(payload, secret_key, algorithm='HS256')
|
@@ -19,6 +22,12 @@ def get_payload(token, secret_key):
|
|
19
22
|
except Exception as e:
|
20
23
|
return None
|
21
24
|
|
25
|
+
def get_token(key):
|
26
|
+
return get_payload(request.get_header(token_header), key)
|
27
|
+
|
28
|
+
def is_valid(key):
|
29
|
+
return get_payload(request.get_header(token_header), key) is not None
|
30
|
+
|
22
31
|
# if __name__ == '__main__':
|
23
32
|
# token = gen_token({"xx": 123}, '123')
|
24
33
|
# xx = get_payload(token, '123')
|
@@ -44,7 +44,7 @@ ctools/string_tools.py,sha256=itK59W4Ed4rQzuyHuioNgDRUcBlfb4ZoZnwmS9cJxiI,1887
|
|
44
44
|
ctools/sys_info.py,sha256=NvKCuBlWHHiW4bDI4tYZUo3QusvODm1HlW6aAkrllnE,4248
|
45
45
|
ctools/sys_log.py,sha256=oqb1S41LosdeZxtogFVgDk8R4sjiHhUeYJLCzHd728E,2805
|
46
46
|
ctools/thread_pool.py,sha256=qb68ULHy1K7u3MC7WP49wDhmgUhgWazd9FRuFbClET4,925
|
47
|
-
ctools/token.py,sha256=
|
47
|
+
ctools/token.py,sha256=NZSBGF3lJajJFLRIZoeXmpp8h5cKM0dAH2weySgeORc,882
|
48
48
|
ctools/upload_tools.py,sha256=sqe6K3ZWiyY58pFE5IO5mNaS1znnS7U4c4UqY8noED4,1068
|
49
49
|
ctools/win_canvas.py,sha256=PAxI4i1jalfree9d1YG4damjc2EzaHZrgHZCTgk2GiM,2530
|
50
50
|
ctools/win_control.py,sha256=35f9x_ijSyc4ZDkcT32e9ZIhr_ffNxadynrQfFuIdYo,3489
|
@@ -52,7 +52,7 @@ ctools/wordFill.py,sha256=dB1OLt6GLmWdkDV8H20VWbJmY4ggNNI8iHD1ocae2iM,875
|
|
52
52
|
ctools/word_fill.py,sha256=xeo-P4DOjQUqd-o9XL3g66wQrE2diUPGwFywm8TdVyw,18210
|
53
53
|
ctools/word_fill_entity.py,sha256=eX3G0Gy16hfGpavQSEkCIoKDdTnNgRRJrFvKliETZK8,985
|
54
54
|
ctools/work_path.py,sha256=OmfYu-Jjg2huRY6Su8zJ_2EGFFhtBZFbobYTwbjJtG4,1817
|
55
|
-
gomyck_tools-1.2.
|
56
|
-
gomyck_tools-1.2.
|
57
|
-
gomyck_tools-1.2.
|
58
|
-
gomyck_tools-1.2.
|
55
|
+
gomyck_tools-1.2.7.dist-info/METADATA,sha256=uS-JVNCRR951EEMSzzMThWcONySUcNIj-lG-uJhF4M0,1108
|
56
|
+
gomyck_tools-1.2.7.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
57
|
+
gomyck_tools-1.2.7.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
|
58
|
+
gomyck_tools-1.2.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|