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
e6852764
Commit
e6852764
authored
7 years ago
by
sim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Add JWT authentication
parent
38c08fe8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
45 deletions
+72
-45
settings.py
gargantext/settings.py
+25
-7
urls.py
gargantext/views/api/urls.py
+46
-38
requirements.txt
install/gargamelle/requirements.txt
+1
-0
No files found.
gargantext/settings.py
View file @
e6852764
...
...
@@ -104,6 +104,24 @@ TEMPLATES = [
WSGI_APPLICATION
=
'gargantext.wsgi.application'
# http://getblimp.github.io/django-rest-framework-jwt/#additional-settings
REST_FRAMEWORK
=
{
'DEFAULT_PERMISSION_CLASSES'
:
(
'rest_framework.permissions.IsAuthenticated'
,
),
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
'rest_framework_jwt.authentication.JSONWebTokenAuthentication'
,
'rest_framework.authentication.SessionAuthentication'
,
'rest_framework.authentication.BasicAuthentication'
,
),
}
JWT_AUTH
=
{
'JWT_VERIFY_EXPIRATION'
:
False
,
'JWT_SECRET_KEY'
:
SECRET_KEY
,
'JWT_AUTH_HEADER_PREFIX'
:
'Bearer'
,
}
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
...
...
@@ -163,15 +181,15 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
API_TOKENS
=
{
API_TOKENS
=
{
"CERN"
:
{
"APIKEY"
:
'b8514451-82d1-408e-a855-56d342a0b5f8'
,
"APISECRET"
:
'6680b13e-2b5a-4fba-8c0e-408884d5b904'
,
},
"MULTIVAC"
:{
"APIKEY"
:
"3a8ca010-1dff-11e7-97ef-a1a6aa4c2352"
}
"APIKEY"
:
'b8514451-82d1-408e-a855-56d342a0b5f8'
,
"APISECRET"
:
'6680b13e-2b5a-4fba-8c0e-408884d5b904'
,
},
"MULTIVAC"
:
{
"APIKEY"
:
"3a8ca010-1dff-11e7-97ef-a1a6aa4c2352"
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/
...
...
This diff is collapsed.
Click to expand it.
gargantext/views/api/urls.py
View file @
e6852764
from
django.conf.urls
import
url
from
rest_framework_jwt.views
import
obtain_jwt_token
from
.
import
nodes
from
.
import
projects
from
.
import
corpora
...
...
@@ -10,78 +12,81 @@ from . import ngramlists
from
.
import
analytics
from
graph.rest
import
Graph
urlpatterns
=
[
url
(
r'^nodes$'
,
nodes
.
NodeListResource
.
as_view
()
)
,
url
(
r'^nodes/(\d+)$'
,
nodes
.
NodeResource
.
as_view
()
)
,
url
(
r'^nodes/(\d+)/having$'
,
nodes
.
NodeListHaving
.
as_view
()
)
,
url
(
r'^nodes/(\d+)/status$'
,
nodes
.
Status
.
as_view
()
)
#Projects
,
url
(
r'^projects$'
,
projects
.
ProjectList
.
as_view
()
)
,
url
(
r'^projects/(\d+)$'
,
projects
.
ProjectView
.
as_view
()
)
#?view=resource
#?view=docs
#Corpora
,
url
(
r'^projects/(\d+)/corpora/(\d+)$'
,
corpora
.
CorpusView
.
as_view
()
)
#?view=source
#?view=title
#?view=analytics
#Sources
#, url(r'^projects/(\d+)/corpora/(\d+)/sources$' , corpora.CorpusSources.as_view() )
#, url(r'^projects/(\d+)/corpora/(\d+)/sources/(\d+)$' , corpora.CorpusSourceView.as_view() )
#Facets
,
url
(
r'^projects/(\d+)/corpora/(\d+)/facets$'
,
nodes
.
CorpusFacet
.
as_view
()
)
#Favorites
,
url
(
r'^projects/(\d+)/corpora/(\d+)/favorites$'
,
nodes
.
CorpusFavorites
.
as_view
()
)
#Metrics
,
url
(
r'^projects/(\d+)/corpora/(\d+)/metrics$'
,
metrics
.
CorpusMetrics
.
as_view
()
)
#GraphExplorer
,
url
(
r'^projects/(\d+)/corpora/(\d+)/explorer$'
,
Graph
.
as_view
())
urlpatterns
=
[
url
(
r'^nodes$'
,
nodes
.
NodeListResource
.
as_view
())
,
url
(
r'^nodes/(\d+)$'
,
nodes
.
NodeResource
.
as_view
())
,
url
(
r'^nodes/(\d+)/having$'
,
nodes
.
NodeListHaving
.
as_view
())
,
url
(
r'^nodes/(\d+)/status$'
,
nodes
.
Status
.
as_view
())
# Projects
,
url
(
r'^projects$'
,
projects
.
ProjectList
.
as_view
())
,
url
(
r'^projects/(\d+)$'
,
projects
.
ProjectView
.
as_view
())
# Corpora
,
url
(
r'^projects/(\d+)/corpora/(\d+)$'
,
corpora
.
CorpusView
.
as_view
())
# Sources
#, url(r'^projects/(\d+)/corpora/(\d+)/sources$', corpora.CorpusSources.as_view())
#, url(r'^projects/(\d+)/corpora/(\d+)/sources/(\d+)$ , corpora.CorpusSourceView.as_view())
# Facets
,
url
(
r'^projects/(\d+)/corpora/(\d+)/facets$'
,
nodes
.
CorpusFacet
.
as_view
())
# Favorites
,
url
(
r'^projects/(\d+)/corpora/(\d+)/favorites$'
,
nodes
.
CorpusFavorites
.
as_view
())
# Metrics
,
url
(
r'^projects/(\d+)/corpora/(\d+)/metrics$'
,
metrics
.
CorpusMetrics
.
as_view
())
# GraphExplorer
,
url
(
r'^projects/(\d+)/corpora/(\d+)/explorer$'
,
Graph
.
as_view
())
# data for graph explorer (json)
# GET /api/projects/43198/corpora/111107/explorer?
# Corresponding view is : /projects/43198/corpora/111107/explorer?
# Parameters (example):
# explorer?field1=ngrams&field2=ngrams&distance=conditional&bridgeness=5&start=1996-6-1&end=2002-10-5
# Ngrams
,
url
(
r'^ngrams/?$'
,
ngrams
.
ApiNgrams
.
as_view
()
)
,
url
(
r'^ngrams/?$'
,
ngrams
.
ApiNgrams
.
as_view
())
# Analytics
,
url
(
r'^nodes/(\d+)/histories$'
,
analytics
.
NodeNgramsQueries
.
as_view
())
,
url
(
r'hyperdata$'
,
analytics
.
ApiHyperdata
.
as_view
()
)
,
url
(
r'hyperdata$'
,
analytics
.
ApiHyperdata
.
as_view
())
# get a list of ngram_ids or ngram_infos by list_id
# url(r'^ngramlists/(\d+)$', ngramlists.List.as_view()),
,
url
(
r'^nodes/(\d+)/facets$'
,
nodes
.
CorpusFacet
.
as_view
()
)
,
url
(
r'^nodes/(\d+)/favorites$'
,
nodes
.
CorpusFavorites
.
as_view
()
)
# in these two routes the node is supposed to be a *corpus* node
,
url
(
r'^nodes/(\d+)/facets$'
,
nodes
.
CorpusFacet
.
as_view
())
,
url
(
r'^nodes/(\d+)/favorites$'
,
nodes
.
CorpusFavorites
.
as_view
())
# in these two routes the node is supposed to be a *corpus* node
,
url
(
r'^metrics/(\d+)$'
,
metrics
.
CorpusMetrics
.
as_view
()
)
,
url
(
r'^metrics/(\d+)$'
,
metrics
.
CorpusMetrics
.
as_view
()
)
# update all metrics for a corpus
# ex: PUT metrics/123
# \
# corpus id
,
url
(
r'^ngramlists/export$'
,
ngramlists
.
CSVLists
.
as_view
()
)
,
url
(
r'^ngramlists/export$'
,
ngramlists
.
CSVLists
.
as_view
())
# get a CSV export of the ngramlists of a corpus
# ex: GET ngramlists/export?corpus=43
# TODO : unify to a /api/ngrams?formatted=csv
# (similar to /api/nodes?formatted=csv)
,
url
(
r'^ngramlists/import$'
,
ngramlists
.
CSVLists
.
as_view
()
)
,
url
(
r'^ngramlists/import$'
,
ngramlists
.
CSVLists
.
as_view
())
# same handling class as export (CSVLists)
# but this route used only for POST + file
# or PATCH + other corpus id
,
url
(
r'^ngramlists/change$'
,
ngramlists
.
ListChange
.
as_view
()
)
,
url
(
r'^ngramlists/change$'
,
ngramlists
.
ListChange
.
as_view
())
# add or remove ngram from a list
# ex: add <=> PUT ngramlists/change?list=42&ngrams=1,2
# rm <=> DEL ngramlists/change?list=42&ngrams=1,2
,
url
(
r'^ngramlists/groups$'
,
ngramlists
.
GroupChange
.
as_view
()
)
,
url
(
r'^ngramlists/groups$'
,
ngramlists
.
GroupChange
.
as_view
())
# modify grouping couples of a group node
# ex: PUT/DEL ngramlists/groups?node=43
# & group data also in url: 767[]=209,640 & 779[]=436,265,385
,
url
(
r'^ngramlists/family$'
,
ngramlists
.
ListFamily
.
as_view
()
)
,
url
(
r'^ngramlists/family$'
,
ngramlists
.
ListFamily
.
as_view
()
)
# entire combination of lists from a corpus, dedicated to termtable
# (or any combination of lists that go together :
# - a mainlist
...
...
@@ -89,8 +94,11 @@ urlpatterns = [ url(r'^nodes$' , nodes.NodeListResource.as_view()
# - an optional maplist
# - an optional grouplist
,
url
(
r'^ngramlists/maplist$'
,
ngramlists
.
MapListGlance
.
as_view
()
)
,
url
(
r'^ngramlists/maplist$'
,
ngramlists
.
MapListGlance
.
as_view
()
)
# fast access to maplist, similarly formatted for termtable
,
url
(
r'^user/parameters/$'
,
users
.
UserParameters
.
as_view
())
,
url
(
r'^user/parameters/$'
,
users
.
UserParameters
.
as_view
())
,
url
(
'^auth/token$'
,
obtain_jwt_token
)
]
This diff is collapsed.
Click to expand it.
install/gargamelle/requirements.txt
View file @
e6852764
...
...
@@ -11,6 +11,7 @@ django-celery==3.2.1
django-pgfields==1.4.4
django-pgjsonb==0.0.23
djangorestframework==3.5.3
djangorestframework-jwt==1.9.0
html5lib==0.9999999
python-igraph>=0.7.1
jdatetime==1.7.2
...
...
This diff is collapsed.
Click to expand it.
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