Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cake-bot
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleksandr Barabash
cake-bot
Commits
a98b9f2b
Commit
a98b9f2b
authored
Oct 25, 2022
by
Oleksandr Barabash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
signature logging updated
parent
6f95af8f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
config.py
config.py
+1
-1
token_helper.py
utils/token_helper.py
+8
-3
No files found.
config.py
View file @
a98b9f2b
...
@@ -26,7 +26,7 @@ class Auth:
...
@@ -26,7 +26,7 @@ class Auth:
TYPE
=
Types
.
BEARER
TYPE
=
Types
.
BEARER
ALGORITHM
=
Algorithms
.
RS256
ALGORITHM
=
Algorithms
.
RS256
TOKEN_TYPE
=
"
jwt
"
TOKEN_TYPE
=
"
JWT
"
ADMIN_LOGIN_SECRET
=
"adminLogin"
ADMIN_LOGIN_SECRET
=
"adminLogin"
ADMIN_PASSW_SECRET
=
"adminPassword"
ADMIN_PASSW_SECRET
=
"adminPassword"
...
...
utils/token_helper.py
View file @
a98b9f2b
...
@@ -131,6 +131,7 @@ class TokenHelper:
...
@@ -131,6 +131,7 @@ class TokenHelper:
# check expiration
# check expiration
if
datetime
.
utcnow
()
.
timestamp
()
>
token_exp
:
if
datetime
.
utcnow
()
.
timestamp
()
>
token_exp
:
Log
.
d
(
__name__
,
"token is expired"
)
return
False
return
False
# TODO(s1z): Cache this please
# TODO(s1z): Cache this please
...
@@ -149,9 +150,13 @@ class TokenHelper:
...
@@ -149,9 +150,13 @@ class TokenHelper:
signature_gen
=
SHA256
.
new
(
token_unsigned
.
encode
(
"utf-8"
))
.
digest
()
signature_gen
=
SHA256
.
new
(
token_unsigned
.
encode
(
"utf-8"
))
.
digest
()
signature_encrypted
=
self
.
azure_kv
.
encrypt_bl
(
key
,
signature_gen
)
signature_encrypted
=
self
.
azure_kv
.
encrypt_bl
(
key
,
signature_gen
)
signature_gen
=
b64encode_np
(
signature_encrypted
)
.
decode
(
"utf-8"
)
signature_gen
=
b64encode_np
(
signature_encrypted
)
.
decode
(
"utf-8"
)
if
signature
!=
signature_gen
:
return
False
Log
.
d
(
__name__
,
f
"is equal: '{signature == signature_gen}'"
)
return
True
Log
.
d
(
__name__
,
f
"signature_gen: '{signature_gen}'"
)
Log
.
d
(
__name__
,
f
"signature: '{signature}'"
)
if
signature
==
signature_gen
:
return
True
return
False
def
is_auth
(
self
,
f
):
def
is_auth
(
self
,
f
):
""" Is auth decorator """
""" Is auth decorator """
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment