From 1c97836c5a9deb047ca51eb4cf471cd1319865f8 Mon Sep 17 00:00:00 2001 From: bio-boris Date: Tue, 15 Dec 2020 11:48:02 -0600 Subject: [PATCH] Add acl status --- staging_service/app.py | 8 ++++++++ staging_service/utils.py | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/staging_service/app.py b/staging_service/app.py index e82f618f..41da1938 100644 --- a/staging_service/app.py +++ b/staging_service/app.py @@ -55,6 +55,14 @@ async def add_acl_concierge(request: web.Request): return web.json_response(result) +@routes.get("/acl-status") +async def add_acl(request: web.Request): + username = await authorize_request(request) + user_dir = Path.validate_path(username).full_path + result = AclManager().acl_status(user_dir) + return web.json_response(result) + + @routes.get("/add-acl") async def add_acl(request: web.Request): username = await authorize_request(request) diff --git a/staging_service/utils.py b/staging_service/utils.py index 58a7c0b3..7aff1fb7 100644 --- a/staging_service/utils.py +++ b/staging_service/utils.py @@ -79,7 +79,7 @@ def validate_path(username: str, path: str = ""): @staticmethod def from_full_path(full_path: str): - user_path = full_path[len(Path._DATA_DIR) :] + user_path = full_path[len(Path._DATA_DIR):] if user_path.startswith("/"): user_path = user_path[1:] metadata_path = os.path.join(Path._META_DIR, user_path) @@ -270,6 +270,23 @@ def add_acl_concierge(self, shared_directory: str, concierge_path: str): return self._add_acl(user_identity_id, concierge_path) + def acl_status(self, shared_directory: str): + """ + Inspect ACLS for user and provide instructions + :param shared_directory: Directory to get globus ID from + :return: Result of status check + """ + user_identity_id = self._get_globus_identity(shared_directory) + base_name = "/{}/".format(shared_directory.split("/")[-2]) + remove_acl = "https://kbase.us/services/staging_service/remove-acl" + add_acl = "https://kbase.us/services/staging_service/add-acl" + return {"base_name": base_name, "user_identity_id": user_identity_id, + "globus_info": f"You must be logged in with {user_identity_id} " + + "in globus to see your directory", + "troubleshooting": f"To reset your globus permissions please visit " + + f"{remove_acl} and then visit {add_acl} " + } + def add_acl(self, shared_directory: str): """ Add ACL to the globus share via the globus API