mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-10 20:51:14 -05:00
This changeset switches AWS service touchpoints to use their FIPS-enabled counterparts. Note that S3 has some specific configuration associated with it. This changeset also updates our allow ACLs to cover the FIPS-enabled endpoints. We should investigate removing the non-FIPS endpoints as a part of this. Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
from botocore.config import Config
|
|
|
|
AWS_CLIENT_CONFIG = Config(
|
|
# This config is required to enable S3 to connect to FIPS-enabled
|
|
# endpoints. See https://aws.amazon.com/compliance/fips/ for more
|
|
# information.
|
|
s3={
|
|
'addressing_style': 'virtual',
|
|
},
|
|
use_fips_endpoint=True
|
|
)
|
|
STATISTICS_REQUESTED = 'requested'
|
|
STATISTICS_DELIVERED = 'delivered'
|
|
STATISTICS_FAILURE = 'failure'
|
|
|
|
|
|
class ClientException(Exception):
|
|
'''
|
|
Base Exceptions for sending notifications that fail
|
|
'''
|
|
pass
|
|
|
|
|
|
class Client(object):
|
|
'''
|
|
Base client for sending notifications.
|
|
'''
|
|
pass
|
|
|
|
|
|
class NotificationProviderClients(object):
|
|
sms_clients = {}
|
|
email_clients = {}
|
|
|
|
def init_app(self, sms_clients, email_clients):
|
|
for client in sms_clients:
|
|
self.sms_clients[client.name] = client
|
|
|
|
for client in email_clients:
|
|
self.email_clients[client.name] = client
|
|
|
|
def get_sms_client(self, name):
|
|
return self.sms_clients.get(name)
|
|
|
|
def get_email_client(self, name):
|
|
return self.email_clients.get(name)
|
|
|
|
def get_client_by_name_and_type(self, name, notification_type):
|
|
assert notification_type in ['email', 'sms'] # nosec B101
|
|
|
|
if notification_type == 'email':
|
|
return self.get_email_client(name)
|
|
|
|
if notification_type == 'sms':
|
|
return self.get_sms_client(name)
|