Skip to content

Commit

Permalink
GP-9549 allow a list of group names to be specified that users can sh…
Browse files Browse the repository at this point in the history
…are jobs with, even if they are not members
  • Loading branch information
liefeld committed Dec 4, 2023
1 parent 5d37f1d commit 0fb053d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/org/genepattern/server/PermissionsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ private void initJobResultPermissions(IGroupMembershipPlugin groupMembership, Se
//get all of the groups which aren't in group permissions
Set<String> groupsToAdd = new HashSet<String>();
groupsToAdd.addAll(groups);
// get the list of groups its always available to share to
ArrayList<String> alwaysShareTo = UserAccountManager.instance().getAlwaysShareableToUserGroups();
groupsToAdd.addAll(alwaysShareTo);

for(GroupPermission gp : groupPermissions) {
String groupId = gp.getGroupId();
groupsToAdd.remove(groupId);
Expand Down
21 changes: 20 additions & 1 deletion src/org/genepattern/server/UserAccountManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.File;
import java.security.NoSuchAlgorithmException;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -40,7 +41,8 @@ public class UserAccountManager {

public static final String PROP_AUTHENTICATION_CLASS = "authentication.class";
public static final String PROP_GROUP_MEMBERSHIP_CLASS = "group.membership.class";

public static final String PROP_GROUPS_ALWAYS_SHAREABLE_TO = "groups.always.shareable.to";

/**
* The 'username.regex' is a regular expression which matches all valid usernames
* and which must not match any invalid usernames. This pattern is used to validate
Expand Down Expand Up @@ -83,6 +85,7 @@ private static class Singleton {
private IAuthenticationPlugin authentication = null;
private IGroupMembershipPlugin groupMembership = null;
private UserGroups userGroups = null;
private ArrayList<String> alwaysShareableUserGroups = null;

//this property is optionally (when set) used in the default group membership class, UserGroups
private File userGroupsXml=null;
Expand Down Expand Up @@ -422,6 +425,11 @@ public UserGroups getUserGroups() {
return userGroups;
}

public ArrayList<String> getAlwaysShareableToUserGroups(){
return this.alwaysShareableUserGroups;
}


/**
* If necessary reload user and groups information by reloading the IAuthenticationPlugin and IGroupMembershipPlugins.
* This supports one specific use-case: when GP default group membership is used, and an admin edits the configuration file,
Expand Down Expand Up @@ -492,6 +500,17 @@ private void loadGroupMembership(final GpConfig gpConfig, String customGroupMemb
this.userGroups = UserGroups.initFromConfig(gpConfig);
}
this.groupMembership = userGroups;

String groupsAlwaysOnShareMenu = gpConfig.getGPProperty(GpContext.getServerContext(), PROP_GROUPS_ALWAYS_SHAREABLE_TO, null);
String[] shareableGroupNames = groupsAlwaysOnShareMenu.split(",");
ArrayList<String> shareableGroupNamesList = new ArrayList<String>();
for (int i=0; i< shareableGroupNames.length; i++ ) {
String nom = shareableGroupNames[i].trim();
if (nom.length() >0) {
shareableGroupNamesList.add(nom);
}
}
this.alwaysShareableUserGroups = shareableGroupNamesList;
}
else {
try {
Expand Down

0 comments on commit 0fb053d

Please sign in to comment.