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

YDA-4101: add ability to create external user with custom creator #340

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ jobs:
cat ../copytovault.log
cat ../publication.log

- name: Output rodsLogs
if: failure()
run: |
docker exec provider.yoda sh -c 'set -x ; cat /var/lib/irods/log/rodsLog*'

# Uncomment section below when needed for debugging.
#
# - name: Setup tmate session for debugging
Expand Down
69 changes: 62 additions & 7 deletions uuGroup.r
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,25 @@ uuGroupGetDescription(*groupName, *description) {
}
}

# \brief Get a list of both manager and non-manager members of a group.
#
# This function ignores zone names, this is usually a bad idea.
#
# \deprecated Use uuGroupGetMembers(*groupName, *includeRo, *addTypePrefix, *members) instead
#
# \param[in] groupName
# \param[out] members a list of user names
#
uuGroupGetMembers(*groupName, *members) {
uuGroupGetMembers(*groupName, false, false, *m);
*members = list();
foreach (*member in *m) {
# Throw away the zone name for backward compat.
uuChop(*member, *name, *_, "#", true);
*members = cons(*name, *members);
}
}

Comment on lines +463 to +481
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added back this function so that --delete and --allow-update options in yoda-clienttools would still work. Otherwise we do not use this function.


# \brief Get a list of a group's members.
#
Expand Down Expand Up @@ -922,17 +941,29 @@ uuUserMetaRemove(*userName, *property, *status, *message) {
}
}

# \brief Add a user to a group.
# \brief Add a user to a group on behalf of another user.
#
# \param[in] groupName
# \param[in] user the user to add to the group
# \param[out] status zero on success, non-zero on failure
# \param[out] message a user friendly error message, may contain the reason why an action was disallowed
# \param[in] user the user to add to the group
# \param[in] creatorUser the user who will add the new user
# \param[in] creatorZone the zone of the user who will add the new user
# \param[out] status zero on success, non-zero on failure
# \param[out] message a user friendly error message, may contain the reason why an action was disallowed
#
uuGroupUserAdd(*groupName, *user, *status, *message) {
uuGroupUserAdd(*groupName, *user, *creatorUser, *creatorZone, *status, *message) {
*status = '1';
*message = "An internal error occurred.";

*fullNameActor = "$userNameClient#$rodsZoneClient";
# Check that the creator user exists
*fullNameCreator = "*creatorUser#*creatorZone";

uuUserExists(*fullNameCreator, *exists);
# If creator does not exist, exit
if (!*exists) {
succeed; # Return here (fail would ruin the status and error message).
}

uuGetUserAndZone(*user, *userName, *userZone);
*fullName = "*userName#*userZone";

Expand All @@ -954,15 +985,24 @@ uuGroupUserAdd(*groupName, *user, *status, *message) {
*externalUser = "";
rule_group_check_external_user(*userName, *externalUser)
if (*externalUser == "1") {
# Confirm that the actor is allowed to perform this action (either admin or the actor is the same as the creator user)
uuGetUserType(*fullNameActor, *actorUserType);
if (*actorUserType == "rodsadmin" || *fullNameCreator == *fullNameActor) {
*http_code = ""
*message = ""
rule_group_provision_external_user(*userName, $userNameClient, $rodsZoneClient, *http_code, *message);
rule_group_provision_external_user(*userName, *creatorUser, *creatorZone, *http_code, *message);
if (*message != "") {
writeLine("serverLog", "[EXTERNAL USER] *message");
*status = *http_code;
succeed; # Return here (fail would ruin the status and error message).
}
writeLine("serverLog", "[EXTERNAL USER] User *userName added by $userNameClient on $rodsZoneClient.");
writeLine("serverLog", "[EXTERNAL USER] User *userName added by $userNameClient on $rodsZoneClient on the behalf of *creatorUser on *creatorZone.");
}
else {
# Actor user is not allowed to do this action
writeLine("serverLog", "[EXTERNAL USER] Actor $userNameClient on $rodsZoneClient does not have sufficient permissions to create external user *userName");
succeed; # Return here (fail would ruin the status and error message).
}
}
}

Expand All @@ -978,6 +1018,21 @@ uuGroupUserAdd(*groupName, *user, *status, *message) {
}
}

# \brief Add a user to a group.
#
# \param[in] groupName
# \param[in] user the user to add to the group
# \param[out] status zero on success, non-zero on failure
# \param[out] message a user friendly error message, may contain the reason why an action was disallowed
#
uuGroupUserAdd(*groupName, *user, *status, *message) {
*status = '1';
*message = "An internal error occurred.";

uuGroupUserAdd(*groupName, *user, $userNameClient, $rodsZoneClient, *status, *message)
}


# \brief Remove a user from a group.
#
# \param[in] groupName
Expand Down
Loading