Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task/WP-682: Fix Community Project Folders on Core portals #1041

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def set_workspace_acls(client, system_id, path, username, operation, role):
}

if settings.PORTAL_PROJECTS_USE_SET_FACL_JOB:
logger.info(f"Using setfacl job to submit ACL change for project: {path}, username: {username}, operation: {operation}, role: {role}")
job_res = submit_workspace_acls_job(username, path, role, operation)
logger.info(f"Using setfacl job to submit ACL change for project: {system_id}, path: {path}, username: {username}, operation: {operation}, role: {role}")
job_res = submit_workspace_acls_job(client, username, system_id, role, operation)
logger.info(f"Submitted workspace ACL job {job_res.name} with UUID {job_res.uuid}")
return

Expand All @@ -73,7 +73,7 @@ def set_workspace_acls(client, system_id, path, username, operation, role):


def submit_workspace_acls_job(
username, project_name, role, action=Literal["add", "remove"]
user_client, username, system_id, role, action=Literal["add", "remove"]
):
"""
Submit a job to set ACLs on a project for a specific user. This should be used if
Expand All @@ -83,8 +83,10 @@ def submit_workspace_acls_job(
client = service_account()
portal_name = settings.PORTAL_NAMESPACE

prj = user_client.systems.getSystem(systemId=system_id)
rstijerina marked this conversation as resolved.
Show resolved Hide resolved

job_body = {
"name": f"setfacl-project-{project_name}-{username}-{action}-{role}",
"name": f"setfacl-project-{system_id}-{username}-{action}-{role}"[:64],
"appId": "setfacl-corral-wmaprtl",
"appVersion": "0.0.1",
"description": "Add/Remove ACLs on a directory",
Expand All @@ -96,7 +98,7 @@ def submit_workspace_acls_job(
{"key": "usernames", "value": username},
{
"key": "directory",
"value": f"{settings.PORTAL_PROJECTS_ROOT_DIR}/{project_name}",
"value": f"{prj.rootDir}",
},
{"key": "action", "value": action},
{"key": "role", "value": role},
Expand Down Expand Up @@ -199,11 +201,10 @@ def add_user_to_workspace(client: Tapis,
"""
Give a user POSIX and Tapis permissions on a workspace system.
"""
service_client = service_account()
system_id = f"{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}.{workspace_id}"
set_workspace_acls(service_client,
settings.PORTAL_PROJECTS_ROOT_SYSTEM_NAME,
workspace_id,
set_workspace_acls(client,
system_id,
"/",
username,
"add",
role)
Expand Down Expand Up @@ -231,8 +232,8 @@ def change_user_role(client, workspace_id: str, username: str, new_role):
service_client = service_account()
system_id = f"{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}.{workspace_id}"
set_workspace_acls(service_client,
settings.PORTAL_PROJECTS_ROOT_SYSTEM_NAME,
workspace_id,
system_id,
"/",
username,
"add",
new_role)
Expand All @@ -247,8 +248,8 @@ def remove_user(client, workspace_id: str, username: str):
service_client = service_account()
system_id = f"{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}.{workspace_id}"
set_workspace_acls(service_client,
settings.PORTAL_PROJECTS_ROOT_SYSTEM_NAME,
workspace_id,
system_id,
"/",
username,
"remove",
"none")
Expand All @@ -271,8 +272,8 @@ def transfer_ownership(client, workspace_id: str, new_owner: str, old_owner: str
service_client = service_account()
system_id = f"{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}.{workspace_id}"
set_workspace_acls(service_client,
settings.PORTAL_PROJECTS_ROOT_SYSTEM_NAME,
workspace_id,
system_id,
"/",
new_owner,
"add",
"writer")
Expand Down Expand Up @@ -352,6 +353,10 @@ def get_project(client, workspace_id):
access = 'edit'
elif perms.permission == 'READ':
access = 'read'
else:
logger.info(f"System shared to user without proper Tapis file permissions: {system_id}, username: {username}")
rstijerina marked this conversation as resolved.
Show resolved Hide resolved
access = 'none'

users.append({"user": get_project_user(username), "access": access})

return {
Expand Down
Loading