Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
6de92f54
Commit
6de92f54
authored
3 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Plain Diff
Merge branch 'anon-bypass-scopes' into 'master'
Ignore user scope checking for unauthenticated users Closes
#554
and
#756
See merge request
!1382
parents
f988d0a0
24683aad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1382
Ignore user scope checking for unauthenticated users
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/images/tests/test_image_api.py
+10
-0
10 additions, 0 deletions
arkindex/images/tests/test_image_api.py
arkindex/project/permissions.py
+2
-2
2 additions, 2 deletions
arkindex/project/permissions.py
with
12 additions
and
2 deletions
arkindex/images/tests/test_image_api.py
+
10
−
0
View file @
6de92f54
...
...
@@ -311,6 +311,16 @@ class TestImageApi(FixtureAPITestCase):
}
})
def
test_create_iiif_image_requires_login
(
self
):
response
=
self
.
client
.
post
(
reverse
(
'
api:iiif-url-create
'
),
{
'
url
'
:
'
https://test-server.eu/images/image_path
'
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
self
.
assertDictEqual
(
response
.
json
(),
{
'
detail
'
:
'
Authentication credentials were not provided.
'
})
def
test_create_iiif_image_scope
(
self
):
self
.
assertFalse
(
self
.
user
.
user_scopes
.
filter
(
scope
=
Scope
.
CreateIIIFImage
).
exists
())
self
.
client
.
force_login
(
self
.
user
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/project/permissions.py
+
2
−
2
View file @
6de92f54
...
...
@@ -39,8 +39,8 @@ class UserScopePermissionMixin(object):
def
has_permission
(
self
,
request
,
view
):
scopes
=
self
.
get_scopes
(
view
,
request
.
method
)
# Skip this permission mixin if there are no defined scopes
or
if the user is an admin
if
not
scopes
or
(
request
.
user
.
is_authenticated
and
request
.
user
.
is_admin
)
:
# Skip this permission mixin if there are no defined scopes
,
if the user is
not logged in or is
an admin
if
not
scopes
or
not
request
.
user
.
is_authenticated
or
request
.
user
.
is_admin
:
return
super
().
has_permission
(
request
,
view
)
missing_scopes
=
set
(
scopes
)
...
...
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