Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
0b31bc5b
Commit
0b31bc5b
authored
4 years ago
by
Mario Raciti
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-521
: Add token-deauth API
parent
0e8cd043
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!327
Resolve TMSS-521
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/TMSS/src/tmss/tmssapp/views.py
+13
-1
13 additions, 1 deletion
SAS/TMSS/src/tmss/tmssapp/views.py
SAS/TMSS/src/tmss/urls.py
+1
-0
1 addition, 0 deletions
SAS/TMSS/src/tmss/urls.py
with
14 additions
and
1 deletion
SAS/TMSS/src/tmss/tmssapp/views.py
+
13
−
1
View file @
0b31bc5b
...
...
@@ -53,13 +53,25 @@ class LoginView(LiW):
password
=
request
.
POST
[
'
password
'
]
user
=
authenticate
(
request
,
username
=
username
,
password
=
password
)
if
user
is
not
None
:
# TODO:
P
rovide a proof of auth to frontend
.
DRF TokenAuthentication: POST /token-auth/
# TODO:
Keep this view or not? We p
rovide a proof of auth to frontend
with
DRF TokenAuthentication: POST /token-auth/
auth
=
login
(
request
,
user
)
return
HttpResponse
(
'
Success!
'
,
content_type
=
'
text/plain
'
)
else
:
return
HttpResponse
(
'
Invalid credentials!
'
,
content_type
=
'
text/plain
'
)
from
django.contrib.auth
import
logout
from
rest_framework.authtoken.models
import
Token
# TODO: Deal with CSRF
def
token_deauth
(
request
,
*
args
,
**
kwargs
):
token
=
request
.
META
[
'
HTTP_AUTHORIZATION
'
].
split
(
"
"
)[
1
]
# FIXME: request.user is None, need to find out a way to link token with user (Token.objects.filter(key=token, user=requests.user)
invalidate_token
=
Token
.
objects
.
filter
(
key
=
token
)
invalidate_token
.
delete
()
# logout(request)
return
HttpResponse
(
'
Success logout!
'
,
content_type
=
'
text/plain
'
)
def
task_specify_observation
(
request
,
pk
=
None
):
task
=
get_object_or_404
(
models
.
TaskDraft
,
pk
=
pk
)
return
HttpResponse
(
"
response
"
,
content_type
=
'
text/plain
'
)
...
...
This diff is collapsed.
Click to expand it.
SAS/TMSS/src/tmss/urls.py
+
1
−
0
View file @
0b31bc5b
...
...
@@ -60,6 +60,7 @@ urlpatterns = [
path
(
'
login/
'
,
views
.
LoginView
.
as_view
(),
name
=
'
login
'
),
path
(
'
logout/
'
,
LogoutView
.
as_view
(),
name
=
'
logout
'
),
path
(
'
token-auth/
'
,
obtain_auth_token
,
name
=
'
token-auth
'
),
path
(
'
token-deauth/
'
,
views
.
token_deauth
,
name
=
'
token-deauth
'
),
path
(
'
docs/
'
,
include_docs_urls
(
title
=
'
TMSS API
'
)),
re_path
(
r
'
^swagger(?P<format>\.json|\.yaml)$
'
,
swagger_schema_view
.
without_ui
(
cache_timeout
=
0
),
name
=
'
schema-json
'
),
path
(
'
swagger/
'
,
swagger_schema_view
.
with_ui
(
'
swagger
'
,
cache_timeout
=
0
),
name
=
'
schema-swagger-ui
'
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment