diff --git a/config/settings/container/base.py b/config/settings/container/base.py index 6836614f4acbc500dcd0c0cc56407d302f9dfe62..de7e7859b7e3df386fc574193ce23713ffd728a1 100644 --- a/config/settings/container/base.py +++ b/config/settings/container/base.py @@ -72,6 +72,22 @@ AWS_SES_REGION_ENDPOINT = get_from_env('AWS_SES_REGION_ENDPOINT', ALERT_EMAIL_FROM = get_from_env('DJANGO_ALERT_EMAIL_FROM') +# Priority server settings ---------------------------------------------------- +PRIORITY_SERVER = False +is_priority_server = get_from_env('DJANGO_PRIORITY_SERVER', None, + fail_if_not_found=False) +if (isinstance(is_priority_server, str) and + is_priority_server.lower() in ['true', 't']): + PRIORITY_SERVER = True + +# If priority server, only allow priority users to the API +if PRIORITY_SERVER: + # Add custom permissions for the API + default_perms = list(REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES']) + default_perms = ['api.permissions.IsPriorityUser'] + default_perms + REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = tuple(default_perms) + + # Database settings ----------------------------------------------------------- DATABASES = { 'default' : { diff --git a/config/settings/container/production.py b/config/settings/container/production.py index ddd14cac0bffcfd6bd4e9197cdf3fb9f895c1e08..8022a81d82ffac3786aa5bdcf956cb99c151297f 100644 --- a/config/settings/container/production.py +++ b/config/settings/container/production.py @@ -1,5 +1,4 @@ # Settings for a production GraceDB instance running in a container -from django.core.exceptions import ImproperlyConfigured from .base import * DEBUG = False @@ -9,21 +8,6 @@ SEND_XMPP_ALERTS = True SEND_PHONE_ALERTS = True SEND_EMAIL_ALERTS = True -# Priority server? -PRIORITY_SERVER = False -is_priority_server = os.environ.get('DJANGO_PRIORITY_SERVER', None) -if (isinstance(is_priority_server, str) and - is_priority_server.lower() in ['true', 't']): - PRIORITY_SERVER = True - -# If priority server, only allow priority users -if PRIORITY_SERVER: - # Add custom permissions for API - default_perms = list(REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES']) - default_perms = ['api.permissions.IsPriorityUser'] + default_perms - REST_FRAMEWORK['DEFAULT_PERMISSION_CLASSES'] = tuple(default_perms) - - # TP, March 2019: for now, it looks infeasible to use multiple databases # since there are many operations which normal LVC users can do that # do a write and then a read very soon after. And we can't rely on @@ -33,6 +17,7 @@ if PRIORITY_SERVER: # reworked properly. I.e. this is a much bigger project than expected # so we're going to have to revisit it at some point. We'll leave the # config here for now. +# if not PRIORITY_SERVER: # # If not a priority server, we use the read-only replica database # # for reads and master for writes. # # The username, password, and database name are all replicated