Merge pull request #9793 from ic4f/dev_config_whiteblack_list_load

Modify loading of email white/blacklists
This commit is contained in:
Dannon
2020-05-21 12:17:49 -04:00
committed by GitHub
5 changed files with 42 additions and 40 deletions
+13 -7
View File
@@ -1260,10 +1260,12 @@
:Description:
E-mail domains blacklist is used for filtering out users that are
using disposable email address during the registration. If their
address domain matches any domain in the blacklist, they are
refused the registration.
Example value 'config/disposable_email_blacklist.conf'
using disposable email addresses at registration. If their
address domain matches any domain on the list, they are refused
registration.
Example value 'email_blacklist.conf'
The value of this option will be resolved with respect to
<config_dir>.
:Default: ``None``
:Type: str
@@ -1276,10 +1278,14 @@
E-mail domains whitelist is used to specify allowed email address
domains. If the list is non-empty and a user attempts registration
using an email address belonging to a domain that is not on the
list, registration will be enied. This is a more restrictive
list, registration will be denied. This is a more restrictive
option than <blacklist_file>, and therefore, in case
<whitelist_file> is defined, <blacklist_file> will be ignored.
:Default: ``disposable_email_whitelist.conf``
<whitelist_file> is set and is not empty, <blacklist_file> will be
ignored.
Example value 'email_whitelist.conf'
The value of this option will be resolved with respect to
<config_dir>.
:Default: ``None``
:Type: str
+6 -18
View File
@@ -488,24 +488,8 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
activation_email = kwargs.get('activation_email')
self.email_from = self.email_from or activation_email
# Get the disposable email domains blacklist file and its contents
self.blacklist_content = None
if self.blacklist_file:
self.blacklist_file = self._in_root_dir(self.blacklist_file)
try:
with open(self.blacklist_file) as f:
self.blacklist_content = [line.rstrip() for line in f]
except IOError:
log.error("CONFIGURATION ERROR: Can't open supplied blacklist file from path: %s", self.blacklist_file)
# Create whitelist file to accept only certain email domains
self.whitelist_content = None
if self.whitelist_file:
try:
with open(self.whitelist_file) as f:
self.whitelist_content = [line.rstrip() for line in f]
except IOError:
log.error("CONFIGURATION ERROR: Can't open supplied whitelist file from path: %s", self.whitelist_file)
self.blacklist_content = self._load_list_from_file(self._in_config_dir(self.blacklist_file)) if self.blacklist_file else None
self.whitelist_content = self._load_list_from_file(self._in_config_dir(self.whitelist_file)) if self.whitelist_file else None
self.persistent_communication_rooms = listify(self.persistent_communication_rooms, do_strip=True)
# The transfer manager and deferred job queue
@@ -745,6 +729,10 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin):
'filters': ['stack']
}
def _load_list_from_file(filepath):
with open(filepath) as f:
return [line.strip() for line in f]
def _set_galaxy_infrastructure_url(self, kwargs):
# indicate if this was not set explicitly, so dependending on the context a better default
# can be used (request url in a web thread, Docker parent in IE stuff, etc.)
+12 -7
View File
@@ -700,19 +700,24 @@ galaxy:
#instance_resource_url: null
# E-mail domains blacklist is used for filtering out users that are
# using disposable email address during the registration. If their
# address domain matches any domain in the blacklist, they are refused
# the registration.
# Example value 'config/disposable_email_blacklist.conf'
# using disposable email addresses at registration. If their address
# domain matches any domain on the list, they are refused
# registration.
# Example value 'email_blacklist.conf'
# The value of this option will be resolved with respect to
# <config_dir>.
#blacklist_file: null
# E-mail domains whitelist is used to specify allowed email address
# domains. If the list is non-empty and a user attempts registration
# using an email address belonging to a domain that is not on the
# list, registration will be enied. This is a more restrictive option
# list, registration will be denied. This is a more restrictive option
# than <blacklist_file>, and therefore, in case <whitelist_file> is
# defined, <blacklist_file> will be ignored.
#whitelist_file: disposable_email_whitelist.conf
# set and is not empty, <blacklist_file> will be ignored.
# Example value 'email_whitelist.conf'
# The value of this option will be resolved with respect to
# <config_dir>.
#whitelist_file: null
# Registration warning message is used to discourage people from
# registering multiple accounts. Applies mostly for the main Galaxy
+11 -7
View File
@@ -930,22 +930,26 @@ mapping:
required: false
desc: |
E-mail domains blacklist is used for filtering out users that are using
disposable email address during the registration. If their address domain
matches any domain in the blacklist, they are refused the registration.
disposable email addresses at registration. If their address domain matches any
domain on the list, they are refused registration.
Example value 'config/disposable_email_blacklist.conf'
Example value 'email_blacklist.conf'
The value of this option will be resolved with respect to <config_dir>.
whitelist_file:
type: str
default: disposable_email_whitelist.conf
path_resolves_to: config_dir
required: false
desc: |
E-mail domains whitelist is used to specify allowed email address domains.
If the list is non-empty and a user attempts registration using an email
address belonging to a domain that is not on the list, registration will be
enied. This is a more restrictive option than <blacklist_file>, and therefore,
in case <whitelist_file> is defined, <blacklist_file> will be ignored.
denied. This is a more restrictive option than <blacklist_file>, and therefore,
in case <whitelist_file> is set and is not empty, <blacklist_file> will be ignored.
Example value 'email_whitelist.conf'
The value of this option will be resolved with respect to <config_dir>.
registration_warning_message:
type: str
-1
View File
@@ -102,7 +102,6 @@ class ExpectedValues:
'tool_sheds_config_file': self._in_config_dir('tool_sheds_conf.xml'),
'tool_test_data_directories': self._in_root_dir('test-data'),
'user_preferences_extra_conf_path': self._in_config_dir('user_preferences_extra_conf.yml'),
'whitelist_file': self._in_config_dir('disposable_email_whitelist.conf'),
'workflow_resource_params_file': self._in_config_dir('workflow_resource_params_conf.xml'),
'workflow_schedulers_config_file': self._in_config_dir('workflow_schedulers_conf.xml'),
}