Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
f1fc7a62
Commit
f1fc7a62
authored
Oct 12, 2017
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[JWT] Map database access control to django auth system
parent
0ef8069e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
settings.py
gargantext/settings.py
+2
-1
jwt.py
gargantext/util/jwt.py
+3
-2
No files found.
gargantext/settings.py
View file @
f1fc7a62
...
...
@@ -126,7 +126,8 @@ JWT_AUTH = {
'JWT_AUTH_HEADER_PREFIX'
:
'Bearer'
,
}
ROLE_ADMIN
=
'gargantua'
ROLE_SUPERUSER
=
'gargantua'
ROLE_STAFF
=
'gargandmin'
ROLE_USER
=
'gargantext'
# Static files (CSS, JavaScript, Images)
...
...
gargantext/util/jwt.py
View file @
f1fc7a62
...
...
@@ -7,9 +7,10 @@ from .dates import datetime
def
jwt_payload_handler
(
user
):
username
=
user
.
username
payload
=
{
'
user_id'
:
user
.
pk
,
'role'
:
settings
.
ROLE_ADMIN
if
username
==
settings
.
ROLE_ADMIN
else
\
'
role'
:
settings
.
ROLE_SUPERUSER
if
user
.
is_superuser
else
\
settings
.
ROLE_STAFF
if
user
.
is_staff
else
\
settings
.
ROLE_USER
,
'user_id'
:
user
.
pk
,
'username'
:
username
,
'exp'
:
datetime
.
now
()
+
api_settings
.
JWT_EXPIRATION_DELTA
}
...
...
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