Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pymongo
Project
Project
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
docker101
pymongo
Commits
a8a79b3b
Commit
a8a79b3b
authored
Sep 01, 2019
by
Ahmad Anvari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add utils for jwt
parent
ede2d6df
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
jwt.py
utils/jwt.py
+7
-5
No files found.
utils/jwt.py
View file @
a8a79b3b
from
authlib.jose
import
jwt
import
jwt
def
generate_jwt
(
user_id
):
def
generate_jwt
(
user_id
):
header
=
{
'alg'
:
'RS256'
}
encoded
=
jwt
.
encode
({
'user_id'
:
user_id
},
'secret'
,
algorithm
=
'HS256'
)
payload
=
{
'iss'
:
'Authlib'
,
'sub'
:
'123'
,
'user_id'
:
user_id
}
return
encoded
.
decode
()
key
=
"SOME_KEY"
.
encode
()
return
jwt
.
encode
(
header
,
payload
,
key
)
def
decode_jwt
(
jwt_token
):
return
jwt
.
decode
(
jwt_token
,
'secret'
,
algorithms
=
[
'HS256'
])
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