Merge pull request #1431 from Netflix/security_notifications_config

Adds an optional interval variable to notification service's
This commit is contained in:
Curtis 2018-07-13 15:51:26 -07:00 committed by GitHub
commit b02c00bbf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 6 deletions

View File

@ -274,7 +274,6 @@ Lemur supports sending certification expiration notifications through SES and SM
LEMUR_SECURITY_TEAM_EMAIL = ['security@example.com'] LEMUR_SECURITY_TEAM_EMAIL = ['security@example.com']
.. data:: LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS .. data:: LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS
:noindex: :noindex:
@ -284,6 +283,15 @@ Lemur supports sending certification expiration notifications through SES and SM
LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS = [30, 15, 2] LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS = [30, 15, 2]
.. data:: LEMUR_SECURITY_TEAM_EMAIL_INTERVALS
:noindex:
Alternate notification interval set for security team notifications. Use this if you would like the default security team notification interval for new certificates to differ from the global default as specified in LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS. If unspecified, the value of LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS is used. Security team default notifications for new certificates can effectively be disabled by setting this value to an empty array.
::
LEMUR_SECURITY_TEAM_EMAIL_INTERVALS = [15, 2]
Authentication Options Authentication Options
---------------------- ----------------------

View File

@ -48,9 +48,11 @@ class CertificateCreationSchema(CertificateSchema):
"DEFAULT_{0}".format(data['owner'].split('@')[0].upper()), "DEFAULT_{0}".format(data['owner'].split('@')[0].upper()),
[data['owner']], [data['owner']],
) )
data['notifications'] += notification_service.create_default_expiration_notifications( data['notifications'] += notification_service.create_default_expiration_notifications(
'DEFAULT_SECURITY', 'DEFAULT_SECURITY',
current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL') current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL'),
current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL_INTERVALS', None)
) )
return data return data

View File

@ -16,10 +16,11 @@ from lemur.common.utils import truthiness
from lemur.notifications.models import Notification from lemur.notifications.models import Notification
def create_default_expiration_notifications(name, recipients): def create_default_expiration_notifications(name, recipients, intervals=None):
""" """
Will create standard 30, 10 and 2 day notifications for a given owner. If standard notifications Will create standard 30, 10 and 2 day notifications for a given owner unless an alternate set of
already exist these will be returned instead of new notifications. intervals is supplied. If standard notifications already exist these will be returned instead of
new notifications.
:param name: :param name:
:param recipients: :param recipients:
@ -48,6 +49,7 @@ def create_default_expiration_notifications(name, recipients):
}, },
] ]
if intervals is None:
intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", [30, 15, 2]) intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", [30, 15, 2])
notifications = [] notifications = []