mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-18 08:02:31 -05:00
Merge pull request #408 from GSA/switch-to-fips
Switch to using FIPS-enabled endpoints
This commit is contained in:
@@ -2,6 +2,8 @@ import botocore
|
|||||||
from boto3 import Session
|
from boto3 import Session
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
from app.clients import AWS_CLIENT_CONFIG
|
||||||
|
|
||||||
FILE_LOCATION_STRUCTURE = 'service-{}-notify/{}.csv'
|
FILE_LOCATION_STRUCTURE = 'service-{}-notify/{}.csv'
|
||||||
|
|
||||||
|
|
||||||
@@ -15,8 +17,12 @@ def get_s3_file(
|
|||||||
def get_s3_object(
|
def get_s3_object(
|
||||||
bucket_name, file_location, access_key, secret_key, region
|
bucket_name, file_location, access_key, secret_key, region
|
||||||
):
|
):
|
||||||
session = Session(aws_access_key_id=access_key, aws_secret_access_key=secret_key, region_name=region)
|
session = Session(
|
||||||
s3 = session.resource('s3')
|
aws_access_key_id=access_key,
|
||||||
|
aws_secret_access_key=secret_key,
|
||||||
|
region_name=region
|
||||||
|
)
|
||||||
|
s3 = session.resource('s3', config=AWS_CLIENT_CONFIG)
|
||||||
return s3.Object(bucket_name, file_location)
|
return s3.Object(bucket_name, file_location)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
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):
|
class ClientException(Exception):
|
||||||
'''
|
'''
|
||||||
Base Exceptions for sending notifications that fail
|
Base Exceptions for sending notifications that fail
|
||||||
@@ -12,11 +28,6 @@ class Client(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
STATISTICS_REQUESTED = 'requested'
|
|
||||||
STATISTICS_DELIVERED = 'delivered'
|
|
||||||
STATISTICS_FAILURE = 'failure'
|
|
||||||
|
|
||||||
|
|
||||||
class NotificationProviderClients(object):
|
class NotificationProviderClients(object):
|
||||||
sms_clients = {}
|
sms_clients = {}
|
||||||
email_clients = {}
|
email_clients = {}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import time
|
|||||||
|
|
||||||
from boto3 import client
|
from boto3 import client
|
||||||
|
|
||||||
from app.clients import Client
|
from app.clients import AWS_CLIENT_CONFIG, Client
|
||||||
from app.cloudfoundry_config import cloud_config
|
from app.cloudfoundry_config import cloud_config
|
||||||
|
|
||||||
|
|
||||||
@@ -18,7 +18,8 @@ class AwsCloudwatchClient(Client):
|
|||||||
"logs",
|
"logs",
|
||||||
region_name=cloud_config.sns_region,
|
region_name=cloud_config.sns_region,
|
||||||
aws_access_key_id=cloud_config.sns_access_key,
|
aws_access_key_id=cloud_config.sns_access_key,
|
||||||
aws_secret_access_key=cloud_config.sns_secret_key
|
aws_secret_access_key=cloud_config.sns_secret_key,
|
||||||
|
config=AWS_CLIENT_CONFIG
|
||||||
)
|
)
|
||||||
super(Client, self).__init__(*args, **kwargs)
|
super(Client, self).__init__(*args, **kwargs)
|
||||||
self.current_app = current_app
|
self.current_app = current_app
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ import botocore
|
|||||||
from boto3 import client
|
from boto3 import client
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
from app.clients import STATISTICS_DELIVERED, STATISTICS_FAILURE
|
from app.clients import (
|
||||||
|
AWS_CLIENT_CONFIG,
|
||||||
|
STATISTICS_DELIVERED,
|
||||||
|
STATISTICS_FAILURE,
|
||||||
|
)
|
||||||
from app.clients.email import (
|
from app.clients.email import (
|
||||||
EmailClient,
|
EmailClient,
|
||||||
EmailClientException,
|
EmailClientException,
|
||||||
@@ -62,7 +66,8 @@ class AwsSesClient(EmailClient):
|
|||||||
'ses',
|
'ses',
|
||||||
region_name=cloud_config.ses_region,
|
region_name=cloud_config.ses_region,
|
||||||
aws_access_key_id=cloud_config.ses_access_key,
|
aws_access_key_id=cloud_config.ses_access_key,
|
||||||
aws_secret_access_key=cloud_config.ses_secret_key
|
aws_secret_access_key=cloud_config.ses_secret_key,
|
||||||
|
config=AWS_CLIENT_CONFIG
|
||||||
)
|
)
|
||||||
super(AwsSesClient, self).__init__(*args, **kwargs)
|
super(AwsSesClient, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import botocore
|
|||||||
import phonenumbers
|
import phonenumbers
|
||||||
from boto3 import client
|
from boto3 import client
|
||||||
|
|
||||||
|
from app.clients import AWS_CLIENT_CONFIG
|
||||||
from app.clients.sms import SmsClient
|
from app.clients.sms import SmsClient
|
||||||
from app.cloudfoundry_config import cloud_config
|
from app.cloudfoundry_config import cloud_config
|
||||||
|
|
||||||
@@ -19,7 +20,8 @@ class AwsSnsClient(SmsClient):
|
|||||||
"sns",
|
"sns",
|
||||||
region_name=cloud_config.sns_region,
|
region_name=cloud_config.sns_region,
|
||||||
aws_access_key_id=cloud_config.sns_access_key,
|
aws_access_key_id=cloud_config.sns_access_key,
|
||||||
aws_secret_access_key=cloud_config.sns_secret_key
|
aws_secret_access_key=cloud_config.sns_secret_key,
|
||||||
|
config=AWS_CLIENT_CONFIG
|
||||||
)
|
)
|
||||||
super(SmsClient, self).__init__(*args, **kwargs)
|
super(SmsClient, self).__init__(*args, **kwargs)
|
||||||
self.current_app = current_app
|
self.current_app = current_app
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
monitoring.us-west-2.amazonaws.com
|
logs-fips.us-east-1.amazonaws.com
|
||||||
email.us-west-2.amazonaws.com
|
monitoring-fips.us-west-2.amazonaws.com
|
||||||
sns.us-east-1.amazonaws.com
|
email-fips.us-west-2.amazonaws.com
|
||||||
|
s3-fips.us-east-1.amazonaws.com
|
||||||
|
s3-fips.us-east-2.amazonaws.com
|
||||||
|
s3-fips.us-west-1.amazonaws.com
|
||||||
|
s3-fips.us-west-2.amazonaws.com
|
||||||
|
sns-fips.us-east-1.amazonaws.com
|
||||||
gov-collector.newrelic.com
|
gov-collector.newrelic.com
|
||||||
egress-proxy-notify-api-demo.apps.internal
|
egress-proxy-notify-api-demo.apps.internal
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
monitoring.us-west-2.amazonaws.com
|
logs.us-gov-west-1.amazonaws.com
|
||||||
email.us-gov-west-1.amazonaws.com
|
monitoring-fips.us-west-2.amazonaws.com
|
||||||
|
monitoring.us-gov-west-1.amazonaws.com
|
||||||
|
email-fips.us-gov-west-1.amazonaws.com
|
||||||
|
s3-fips.us-gov-east-1.amazonaws.com
|
||||||
|
s3-fips.us-gov-west-1.amazonaws.com
|
||||||
sns.us-gov-west-1.amazonaws.com
|
sns.us-gov-west-1.amazonaws.com
|
||||||
gov-collector.newrelic.com
|
gov-collector.newrelic.com
|
||||||
egress-proxy-notify-api-production.apps.internal
|
egress-proxy-notify-api-production.apps.internal
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
logs.us-west-2.amazonaws.com
|
logs-fips.us-west-2.amazonaws.com
|
||||||
monitoring.us-west-2.amazonaws.com
|
monitoring-fips.us-west-2.amazonaws.com
|
||||||
email.us-west-2.amazonaws.com
|
email-fips.us-west-2.amazonaws.com
|
||||||
sns.us-west-2.amazonaws.com
|
s3-fips.us-east-1.amazonaws.com
|
||||||
|
s3-fips.us-east-2.amazonaws.com
|
||||||
|
s3-fips.us-west-1.amazonaws.com
|
||||||
|
s3-fips.us-west-2.amazonaws.com
|
||||||
|
sns-fips.us-west-2.amazonaws.com
|
||||||
gov-collector.newrelic.com
|
gov-collector.newrelic.com
|
||||||
egress-proxy-notify-api-staging.apps.internal
|
egress-proxy-notify-api-staging.apps.internal
|
||||||
|
|||||||
Reference in New Issue
Block a user