aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/authorisation/data
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-03-19 22:05:56 +0300
committerMunyoki Kilyungi2024-03-21 10:07:08 +0300
commit7107b2b99058835bf0115955c3e79c23f9fb6bc9 (patch)
tree37a412d506aa47a213286531b466b2ff85d442ba /gn_auth/auth/authorisation/data
parentf7c41fa2f24d96c3024930b1bb603f566f402644 (diff)
downloadgn-auth-7107b2b99058835bf0115955c3e79c23f9fb6bc9.tar.gz
Revert "Add an extra endpoint for metadata authorisation."
This reverts commit f5e833c0d72eaec80425203b15210ed304cc4811. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn_auth/auth/authorisation/data')
-rw-r--r--gn_auth/auth/authorisation/data/views.py50
1 files changed, 0 insertions, 50 deletions
diff --git a/gn_auth/auth/authorisation/data/views.py b/gn_auth/auth/authorisation/data/views.py
index c40b667..01fffcd 100644
--- a/gn_auth/auth/authorisation/data/views.py
+++ b/gn_auth/auth/authorisation/data/views.py
@@ -335,53 +335,3 @@ def link_phenotype() -> Response:
return jsonify(with_db_connection(
partial(__link__, **__values__(request.json))))
-
-
-@data.route("/metadata/authorisation", methods=["POST"])
-@require_json
-def metadata_resources() -> Response:
- """Retrieve the authorisation level for given metadata resources"""
- db_uri, privileges = app.config["AUTH_DB"], {}
- user = User(uuid.uuid4(), "anon@ymous.user", "Anonymous User")
- with db.connection(db_uri) as auth_conn:
- with require_oauth.acquire("profile group resource") as token:
- resources = attach_resources_data(
- auth_conn, user_resources(auth_conn, token.user)
- )
- roles = user_resource_roles(
- auth_conn, token.user
- )
- privileges = {
- resource_id: tuple(
- privilege.privilege_id
- for role in roles[resource_id]
- for privilege in role.privileges)
- for resource_id, is_authorised
- in authorised_for(
- auth_conn, token.user,
- ("group:resource:view-resource",),
- tuple(
- resource.resource_id for resource
- in resources
- )
- ).items()
- if is_authorised
- } | {
- resource.resource_id: ("system:resource:public-read",)
- for resource in resources if resource.public
- }
- resource_map = {
- resource.resource_category.resource_category_key.lower():
- resource.resource_id
- for resource in resources
- for item in resource.resource_data
- }
- return jsonify(
- {
- "user": asdict(user),
- "resource_id": resource_map.get(
- request.json.get("name") #type: ignore[union-attr]
- ),
- "privileges": privileges,
- }
- )