Skip to content

Commit ebb5f21

Browse files
authored
Drop: share_queried_objects capability (#1004)
* Drop: share_queried_objects capability * Fix capabilities list * Remove test for share_queried_objects
1 parent e3a87a7 commit ebb5f21

File tree

7 files changed

+0
-49
lines changed

7 files changed

+0
-49
lines changed

docs/user-guide/9-Sharing-objects.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ Each capability has its own name and scope:
148148

149149
Allows to access all users and groups in MWDB. Rules described in *Who is who?* don't apply to users with that permission. Enables user to create new user accounts, new groups and change their capabilities and membership. Allows to manage attribute keys, define new ones, delete and set the group permissions for them.
150150

151-
*
152-
**share_queried_objects - Query for all objects in system**
153-
154-
That one is a bit tricky and will be possibly deprecated. MWDB will automatically share object and all descendants with group if member directly accessed it via identifier (knows the hash e.g. have direct link to the object). It can be used for bot accounts, so they have access only to these objects that are intended to be processed by them. Internally, we abandoned that idea, so that capability may not be stable.
155-
156151
*
157152
**access_all_objects - Has access to all uploaded objects into system**
158153

mwdb/core/capabilities.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
class Capabilities(object):
22
# Can create/update users and groups
33
manage_users = "manage_users"
4-
# Queried objects by members are automatically shared with this group
5-
share_queried_objects = "share_queried_objects"
64
# All new uploaded objects are automatically shared with this group
75
access_all_objects = "access_all_objects"
86
# Can share objects with all groups, have access to complete list of groups

mwdb/core/deprecated.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ class DeprecatedFeature(Enum):
1717
# API keys non-complaint with RFC7519
1818
# Deprecated in v2.7.0
1919
legacy_api_key_v2 = "legacy_api_key_v2"
20-
# Legacy /request/sample/<token>
21-
# Use /file/<id>/download instead
22-
# Deprecated in v2.2.0
23-
legacy_file_download = "legacy_file_download"
2420
# Legacy Metakey API
2521
# Use Attribute API instead
2622
# Deprecated in v2.6.0

mwdb/model/object.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,6 @@ def access(cls, identifier, requestor=None):
475475
(default: currently authenticated user)
476476
:return: Object instance or None
477477
"""
478-
from .group import Group
479-
480478
if requestor is None:
481479
requestor = g.auth_user
482480

@@ -489,23 +487,6 @@ def access(cls, identifier, requestor=None):
489487
if obj.has_explicit_access(requestor):
490488
return obj
491489

492-
# If not, but has "share_queried_objects" rights: give_access
493-
if requestor.has_rights(Capabilities.share_queried_objects):
494-
share_queried_groups = (
495-
db.session.query(Group)
496-
.filter(
497-
and_(
498-
Group.capabilities.contains(
499-
[Capabilities.share_queried_objects]
500-
),
501-
requestor.is_member(Group.id),
502-
)
503-
)
504-
.all()
505-
)
506-
for group in share_queried_groups:
507-
obj.give_access(group.id, AccessType.QUERIED, obj, requestor)
508-
return obj
509490
# Well.. I've tried
510491
return None
511492

mwdb/web/src/commons/auth/capabilities.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Capability } from "@mwdb-web/types/types";
44
export let capabilitiesList: Record<Capability, string> = {
55
[Capability.manageUsers]:
66
"Managing users and groups (system administration)",
7-
[Capability.shareQueriedObjects]: "Query for all objects in system",
87
[Capability.accessAllObjects]:
98
"Has access to all new uploaded objects into system",
109
[Capability.sharingWithAll]: "Can share objects with all groups in system",

mwdb/web/src/types/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { AxiosError } from "axios";
22

33
export enum Capability {
44
manageUsers = "manage_users",
5-
shareQueriedObjects = "share_queried_objects",
65
accessAllObjects = "access_all_objects",
76
sharingWithAll = "sharing_with_all",
87
accessUploaderInfo = "access_uploader_info",

tests/backend/test_permissions.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,6 @@ def request(*args, **kwargs):
3030
request("PUT", "/group/{}".format(group_name), json={"capabilities": []})
3131

3232

33-
def test_share_queried_objects(admin_session):
34-
testCase = RelationTestCase(admin_session)
35-
36-
Alice = testCase.new_user("Alice")
37-
Bob = testCase.new_user("Bob", capabilities=["share_queried_objects"])
38-
39-
Sample = testCase.new_sample("Sample")
40-
41-
with ShouldRaise(status_code=404):
42-
Alice.session.get_sample(Sample.dhash)
43-
44-
Bob.session.get_sample(Sample.dhash)
45-
46-
Sample.should_not_access(Alice)
47-
Sample.should_access(Bob)
48-
49-
5033
def test_access_all_objects(admin_session):
5134
testCase = RelationTestCase(admin_session)
5235

0 commit comments

Comments
 (0)