Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
ed098407
Commit
ed098407
authored
7 years ago
by
Megan Henning
Browse files
Options
Downloads
Patches
Plain Diff
Add additional 403 error info
parent
0185d4b9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/auth/containerauth.py
+12
-5
12 additions, 5 deletions
api/auth/containerauth.py
api/handlers/containerhandler.py
+3
-1
3 additions, 1 deletion
api/handlers/containerhandler.py
api/web/errors.py
+4
-1
4 additions, 1 deletion
api/web/errors.py
with
19 additions
and
7 deletions
api/auth/containerauth.py
+
12
−
5
View file @
ed098407
...
...
@@ -14,7 +14,7 @@ def default_container(handler, container=None, target_parent_container=None):
def
g
(
exec_op
):
def
f
(
method
,
_id
=
None
,
payload
=
None
,
unset_payload
=
None
,
recursive
=
False
,
r_payload
=
None
,
replace_metadata
=
False
):
projection
=
None
additional_
error
_msg
=
None
error
s
=
None
if
method
==
'
GET
'
and
container
.
get
(
'
public
'
,
False
):
has_access
=
True
elif
method
==
'
GET
'
:
...
...
@@ -31,7 +31,16 @@ def default_container(handler, container=None, target_parent_container=None):
required_perm
=
'
admin
'
else
:
required_perm
=
'
rw
'
has_access
=
_get_access
(
handler
.
uid
,
container
)
>=
INTEGER_PERMISSIONS
[
required_perm
]
user_perms
=
_get_access
(
handler
.
uid
,
container
)
has_access
=
user_perms
>=
INTEGER_PERMISSIONS
[
required_perm
]
if
not
has_access
and
has_original_data
and
user_perms
==
INTEGER_PERMISSIONS
[
'
rw
'
]:
# The user was not granted access because the container had original data
errors
=
{
'
reason
'
:
'
original_data_present
'
}
else
:
errors
=
{
'
reason
'
:
'
permission_denied
'
}
elif
method
==
'
PUT
'
and
target_parent_container
is
not
None
:
has_access
=
(
_get_access
(
handler
.
uid
,
container
)
>=
INTEGER_PERMISSIONS
[
'
admin
'
]
and
...
...
@@ -47,9 +56,7 @@ def default_container(handler, container=None, target_parent_container=None):
return
exec_op
(
method
,
_id
=
_id
,
payload
=
payload
,
unset_payload
=
unset_payload
,
recursive
=
recursive
,
r_payload
=
r_payload
,
replace_metadata
=
replace_metadata
,
projection
=
projection
)
else
:
error_msg
=
'
user not authorized to perform a {} operation on the container.
'
.
format
(
method
)
if
additional_error_msg
:
error_msg
+=
'
'
+
additional_error_msg
handler
.
abort
(
403
,
error_msg
)
raise
APIPermissionException
(
error_msg
,
errors
=
errors
)
return
f
return
g
...
...
This diff is collapsed.
Click to expand it.
api/handlers/containerhandler.py
+
3
−
1
View file @
ed098407
...
...
@@ -544,9 +544,11 @@ class ContainerHandler(base.RequestHandler):
target_parent_container
,
_
=
self
.
_get_parent_container
(
container
)
permchecker
=
self
.
_get_permchecker
(
container
,
target_parent_container
)
permchecker
(
noop
)(
'
DELETE
'
,
_id
)
try
:
# This line exec the actual delete checking permissions using the decorator permchecker
result
=
permchecker
(
self
.
storage
.
exec_op
)
(
'
DELETE
'
,
_id
)
result
=
self
.
storage
.
exec_op
(
'
DELETE
'
,
_id
)
except
APIStorageException
as
e
:
self
.
abort
(
400
,
e
.
message
)
if
result
.
modified_count
==
1
:
...
...
This diff is collapsed.
Click to expand it.
api/web/errors.py
+
4
−
1
View file @
ed098407
...
...
@@ -15,7 +15,10 @@ class APINotFoundException(Exception):
pass
class
APIPermissionException
(
Exception
):
pass
def
__init__
(
self
,
msg
,
errors
=
None
):
super
(
APIPermissionException
,
self
).
__init__
(
msg
)
self
.
errors
=
errors
class
APIRefreshTokenException
(
Exception
):
# Specifically alert a client when the user's refresh token expires
...
...
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