Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalBackend
Commits
ca3d7553
Commit
ca3d7553
authored
Jun 18, 2018
by
Lukas Burgey
Browse files
Implement handling of credentials from the client
parent
179c1bb1
Changes
3
Hide whitespace changes
Inline
Side-by-side
django_backend/backend/auth/v1/client_views.py
View file @
ca3d7553
...
...
@@ -219,7 +219,6 @@ def topic_endpoint(request):
if
service_name
==
service
.
name
:
return
ALLOW
elif
name
==
'sites'
:
LOGGER
.
debug
(
routing_key
)
if
routing_key
==
user
.
site
.
name
:
return
ALLOW
else
:
...
...
django_backend/backend/clientapi/views.py
View file @
ca3d7553
...
...
@@ -58,7 +58,8 @@ class ResponseView(views.APIView):
authentication_classes
=
AUTHENTICATION_CLASSES
def
post
(
self
,
request
):
status
=
request
.
data
[
'output'
][
'status'
]
output
=
request
.
data
[
'output'
]
status
=
output
[
'status'
]
task_id
=
request
.
data
[
'id'
]
LOGGER
.
debug
(
'%s responded to task %s:
\n
%s'
,
request
.
user
,
task_id
,
request
.
data
)
...
...
@@ -71,16 +72,21 @@ class ResponseView(views.APIView):
if
task_item
is
not
None
:
if
status
==
'success'
:
task_item
.
done
()
return
Response
({
'ok'
:
True
})
task_item
.
success
(
credentials
=
request
.
data
.
output
.
get
(
'credentials'
,
None
),
)
return
Response
({})
elif
status
==
'fail'
:
task_item
.
failed
()
return
Response
({
'ok'
:
True
})
return
Response
({})
elif
status
==
'reject'
:
task_item
.
rejected
(
request
.
data
[
'
output
'
]
[
'questionnaire'
])
return
Response
({
'ok'
:
True
})
task_item
.
rejected
(
output
[
'questionnaire'
])
return
Response
({})
LOGGER
.
info
(
'%s executed the obsolete task#%s'
,
request
.
user
,
task_id
)
return
Response
({
'ok'
:
False
})
return
Response
(
data
=
{
'error'
:
'obsolete_task'
},
status
=
500
,
)
django_backend/backend/models.py
View file @
ca3d7553
...
...
@@ -839,6 +839,9 @@ class DeploymentTask(models.Model):
def
questionnaire_default
():
return
{}
def
credential_default
():
return
{}
# DeploymentTaskItem: knows:
# user, service, key, action, _and_ site
class
DeploymentTaskItem
(
models
.
Model
):
...
...
@@ -877,6 +880,12 @@ class DeploymentTaskItem(models.Model):
blank
=
True
,
)
credentials
=
JSONField
(
default
=
credential_default
,
null
=
True
,
blank
=
True
,
)
@
property
def
service
(
self
):
return
self
.
task
.
service
...
...
@@ -890,14 +899,19 @@ class DeploymentTaskItem(models.Model):
return
self
.
deployment
.
key
# the client acked the receipt and execution of the task for his site
def
success
(
self
):
def
success
(
self
,
credentials
=
None
):
task
=
self
.
task
self
.
credentials
=
credentials
self
.
save
()
LOGGER
.
debug
(
self
.
msg
(
'success'
))
self
.
delete
()
# TODO test: does not deleting the task item work?
# self.delete()
task
.
send_state_update
()
task
.
try_finished
()
# TODO test: does not deleting the task work?
#task.try_finished()
# the user changed the deployment
# chancel (delete) this task item
...
...
@@ -963,7 +977,6 @@ class DeploymentTaskItem(models.Model):
return
'[Depl. TaskItem:{}] {}'
.
format
(
self
,
msg
)
#
# RECEIVERS
#
...
...
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