about summary refs log tree commit diff
path: root/gn_auth/auth/authorisation/data/views.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-06-09 12:53:58 -0500
committerFrederick Muriuki Muriithi2025-06-09 12:53:58 -0500
commit1fb89d6ec14db63ef57573260d2996fd3d169f5e (patch)
treeeb65759357dc247fca057ed0bdd02420950e4c3c /gn_auth/auth/authorisation/data/views.py
parent183076a4ae6b7d0f7e8c5369111ae79e5cad04ba (diff)
downloadgn-auth-1fb89d6ec14db63ef57573260d2996fd3d169f5e.tar.gz
Use more flexible check for authorisation.
Use the more flexible check for authorisation that a user has on a
specific resource.
Diffstat (limited to 'gn_auth/auth/authorisation/data/views.py')
-rw-r--r--gn_auth/auth/authorisation/data/views.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/gn_auth/auth/authorisation/data/views.py b/gn_auth/auth/authorisation/data/views.py
index fc20e86..9123949 100644
--- a/gn_auth/auth/authorisation/data/views.py
+++ b/gn_auth/auth/authorisation/data/views.py
@@ -312,6 +312,7 @@ def link_mrna() -> Response:
         partial(__link__, **__values__(request_json()))))
 
 @data.route("/link/phenotype", methods=["POST"])
+@require_oauth("profile group resource")
 def link_phenotype() -> Response:
     """Link phenotype data to group."""
     def __values__(form):
@@ -331,7 +332,8 @@ def link_phenotype() -> Response:
             "using_raw_ids": bool(form.get("using-raw-ids") == "on")
         }
 
-    with gn3db.database_connection(app.config["SQL_URI"]) as gn3conn:
+    with (require_oauth.acquire("profile group resource") as token,
+          gn3db.database_connection(app.config["SQL_URI"]) as gn3conn):
         def __link__(
                 conn: db.DbConnection,
                 group_id: uuid.UUID,
@@ -340,9 +342,11 @@ def link_phenotype() -> Response:
         ) -> dict:
             if using_raw_ids:
                 return link_phenotype_data(conn,
+                                           token.user,
                                            group_by_id(conn, group_id),
                                            traits)
             return link_phenotype_data(conn,
+                                       token.user,
                                        group_by_id(conn, group_id),
                                        pheno_traits_from_db(gn3conn, traits))