Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalBackend
Commits
e432e3d2
Commit
e432e3d2
authored
Nov 28, 2018
by
Lukas Burgey
Browse files
Add auth check for service exchange
parent
264736a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
feudal/backend/auth/v1/views/clients.py
View file @
e432e3d2
...
...
@@ -229,13 +229,20 @@ def topic_endpoint_apiclient(request, apiclient):
name
=
request
.
POST
.
get
(
'name'
,
''
)
routing_key
=
request
.
POST
.
get
(
'routing_key'
,
''
)
if
name
==
'groups'
:
if
name
==
'groups'
or
name
==
'entitlements'
:
try
:
group
=
Group
.
objects
.
get
(
name
=
routing_key
)
vo
=
None
if
name
==
'groups'
:
vo
=
Group
.
objects
.
get
(
name
=
routing_key
)
elif
name
==
'entitlements'
:
vo
=
Entitlement
.
objects
.
get
(
# we strip the group authority from the routing key if it was included
name
=
Entitlement
.
extract_name
(
routing_key
),
)
try
:
models
.
Site
.
objects
.
get
(
services__vos
=
group
,
services__vos
=
vo
,
client
=
apiclient
,
)
return
topic_auth_decision
(
request
,
ALLOW
)
...
...
@@ -246,19 +253,17 @@ def topic_endpoint_apiclient(request, apiclient):
except
models
.
Site
.
DoesNotExist
:
return
topic_auth_decision
(
request
,
DENY
)
except
Group
.
DoesNotExist
:
except
(
Group
.
DoesNotExist
,
Entitlement
.
DoesNotExist
):
LOGGER
.
error
(
'VO does not exist: %s'
,
routing_key
)
return
topic_auth_decision
(
request
,
DENY
)
if
name
==
'
entitlement
s'
:
el
if
name
==
'
service
s'
:
try
:
entitlement
=
Entitlement
.
objects
.
get
(
# we strip the group authority from the routing key if it was included
name
=
Entitlement
.
extract_name
(
routing_key
),
)
service
=
models
.
Service
.
objects
.
get
(
name
=
routing_key
)
try
:
models
.
Site
.
objects
.
get
(
services
__vos
=
entitlement
,
services
=
service
,
client
=
apiclient
,
)
return
topic_auth_decision
(
request
,
ALLOW
)
...
...
@@ -269,8 +274,8 @@ def topic_endpoint_apiclient(request, apiclient):
except
models
.
Site
.
DoesNotExist
:
return
topic_auth_decision
(
request
,
DENY
)
except
Entitlement
.
DoesNotExist
:
LOGGER
.
error
(
'
Entitlement
does not exist: %s'
,
routing_key
)
except
models
.
Service
.
DoesNotExist
:
LOGGER
.
error
(
'
Service
does not exist: %s'
,
routing_key
)
return
topic_auth_decision
(
request
,
DENY
)
return
topic_auth_decision
(
request
,
DENY
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment