diff --git a/config/galaxy.ini.sample b/config/galaxy.ini.sample index 814ef564443..f4a8d8f0172 100644 --- a/config/galaxy.ini.sample +++ b/config/galaxy.ini.sample @@ -786,6 +786,14 @@ use_interactive = True # public. #new_user_dataset_access_role_default_private = False +# Expose user list. Setting this to true will expose the user list to authenticated users. This +# makes sharing datasets in smaller galaxy instances much easier as they can type a name/email and +# have the correct user show up. This makes less sense on large public galaxy instances where +# that data shouldn't be exposed. For semi-public galaxies, it may make sense to expose just the +# username and not email, or vice versa. +#expose_user_name = False +#expose_user_email = False + # -- Beta features # Use new tool form diff --git a/lib/galaxy/config.py b/lib/galaxy/config.py index 9103f0cc927..627b801f97f 100644 --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -106,6 +106,9 @@ class Configuration( object ): self.user_label_filters = listify( kwargs.get( "user_tool_label_filters", [] ), do_strip=True ) self.user_section_filters = listify( kwargs.get( "user_tool_section_filters", [] ), do_strip=True ) + self.expose_user_name = kwargs.get( "expose_user_name", False ) + self.expose_user_email = kwargs.get( "expose_user_email", False ) + # Check for tools defined in the above non-shed tool configs (i.e., tool_conf.xml) tht have # been migrated from the Galaxy code distribution to the Tool Shed. self.check_migrate_tools = string_as_bool( kwargs.get( 'check_migrate_tools', True ) ) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index af23da816b7..cb1bc27687d 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -131,7 +131,7 @@ class User( object, Dictifiable ): histories, credentials, and roles. """ # attributes that will be accessed and returned when calling to_dict( view='collection' ) - dict_collection_visible_keys = ( 'id', 'email' ) + dict_collection_visible_keys = ( 'id', 'email', 'username' ) # attributes that will be accessed and returned when calling to_dict( view='element' ) dict_element_visible_keys = ( 'id', 'email', 'username', 'total_disk_usage', 'nice_total_disk_usage' ) diff --git a/lib/galaxy/webapps/galaxy/api/users.py b/lib/galaxy/webapps/galaxy/api/users.py index 6a3cea2be02..5b98b485b7f 100644 --- a/lib/galaxy/webapps/galaxy/api/users.py +++ b/lib/galaxy/webapps/galaxy/api/users.py @@ -43,11 +43,19 @@ class UserAPIController( BaseAPIController, UsesTagsMixin, CreatesUsersMixin, Cr else: query = query.filter( trans.app.model.User.table.c.deleted == False ) # noqa # special case: user can see only their own user - if not trans.user_is_admin(): + # special case2: if the galaxy admin has specified that other user email/names are + # exposed, we don't want special case #1 + if not trans.user_is_admin() and not trans.app.config.expose_user_name and not trans.app.config.expose_user_email: item = trans.user.to_dict( value_mapper={ 'id': trans.security.encode_id } ) return [item] for user in query: item = user.to_dict( value_mapper={ 'id': trans.security.encode_id } ) + # If NOT configured to expose_email, do not expose email UNLESS the user is self, or + # the user is an admin + if not trans.app.config.expose_user_name and user is not trans.user and not trans.user_is_admin(): + del item['username'] + if not trans.app.config.expose_user_email and user is not trans.user and not trans.user_is_admin(): + del item['email'] # TODO: move into api_values rval.append( item ) return rval diff --git a/templates/webapps/galaxy/history/share.mako b/templates/webapps/galaxy/history/share.mako index fc778cdf252..98fea0911ba 100644 --- a/templates/webapps/galaxy/history/share.mako +++ b/templates/webapps/galaxy/history/share.mako @@ -36,10 +36,10 @@