Merge pull request #39 from kevgliss/notificationInterval
Notification interval
This commit is contained in:
commit
95ac5245e1
|
@ -220,7 +220,8 @@ def create(**kwargs):
|
||||||
notifications += notification_service.create_default_expiration_notifications(notification_name, [cert.owner])
|
notifications += notification_service.create_default_expiration_notifications(notification_name, [cert.owner])
|
||||||
|
|
||||||
notification_name = 'DEFAULT_SECURITY'
|
notification_name = 'DEFAULT_SECURITY'
|
||||||
notifications += notification_service.create_default_expiration_notifications(notification_name, current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL'))
|
notifications += notification_service.create_default_expiration_notifications(notification_name,
|
||||||
|
current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL'))
|
||||||
cert.notifications = notifications
|
cert.notifications = notifications
|
||||||
|
|
||||||
database.update(cert)
|
database.update(cert)
|
||||||
|
|
|
@ -178,6 +178,9 @@ def create_default_expiration_notifications(name, recipients):
|
||||||
:param name:
|
:param name:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
if not recipients:
|
||||||
|
return []
|
||||||
|
|
||||||
options = [
|
options = [
|
||||||
{
|
{
|
||||||
'name': 'unit',
|
'name': 'unit',
|
||||||
|
@ -198,7 +201,7 @@ def create_default_expiration_notifications(name, recipients):
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS")
|
intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", [30, 15, 2])
|
||||||
|
|
||||||
notifications = []
|
notifications = []
|
||||||
for i in intervals:
|
for i in intervals:
|
||||||
|
|
|
@ -14,6 +14,7 @@ from json import dumps
|
||||||
import arrow
|
import arrow
|
||||||
import requests
|
import requests
|
||||||
from requests.adapters import HTTPAdapter
|
from requests.adapters import HTTPAdapter
|
||||||
|
from requests.exceptions import ConnectionError
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
|
@ -23,8 +24,6 @@ from lemur.plugins import lemur_cloudca as cloudca
|
||||||
|
|
||||||
from lemur.authorities import service as authority_service
|
from lemur.authorities import service as authority_service
|
||||||
|
|
||||||
API_ENDPOINT = '/v1/ca/netflix' # TODO this should be configurable
|
|
||||||
|
|
||||||
|
|
||||||
class CloudCAException(LemurException):
|
class CloudCAException(LemurException):
|
||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
|
@ -172,7 +171,11 @@ class CloudCA(object):
|
||||||
|
|
||||||
# we set a low timeout, if cloudca is down it shouldn't bring down
|
# we set a low timeout, if cloudca is down it shouldn't bring down
|
||||||
# lemur
|
# lemur
|
||||||
|
try:
|
||||||
response = self.session.post(self.url + endpoint, data=data, timeout=10, verify=self.ca_bundle)
|
response = self.session.post(self.url + endpoint, data=data, timeout=10, verify=self.ca_bundle)
|
||||||
|
except ConnectionError:
|
||||||
|
raise Exception("Could not talk to CloudCA, is it up?")
|
||||||
|
|
||||||
return process_response(response)
|
return process_response(response)
|
||||||
|
|
||||||
def get(self, endpoint):
|
def get(self, endpoint):
|
||||||
|
@ -182,7 +185,11 @@ class CloudCA(object):
|
||||||
:param endpoint:
|
:param endpoint:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
response = self.session.get(self.url + endpoint, timeout=10, verify=self.ca_bundle)
|
response = self.session.get(self.url + endpoint, timeout=10, verify=self.ca_bundle)
|
||||||
|
except ConnectionError:
|
||||||
|
raise Exception("Could not talk to CloudCA, is it up?")
|
||||||
|
|
||||||
return process_response(response)
|
return process_response(response)
|
||||||
|
|
||||||
def random(self, length=10):
|
def random(self, length=10):
|
||||||
|
@ -202,7 +209,7 @@ class CloudCA(object):
|
||||||
|
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
endpoint = '{0}/listCAs'.format(API_ENDPOINT)
|
endpoint = '{0}/listCAs'.format(current_app.config.get('CLOUDCA_API_ENDPOINT'))
|
||||||
authorities = []
|
authorities = []
|
||||||
for ca in self.get(endpoint)['data']['caList']:
|
for ca in self.get(endpoint)['data']['caList']:
|
||||||
try:
|
try:
|
||||||
|
@ -230,7 +237,7 @@ class CloudCAIssuerPlugin(IssuerPlugin, CloudCA):
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
# this is weird and I don't like it
|
# this is weird and I don't like it
|
||||||
endpoint = '{0}/createCA'.format(API_ENDPOINT)
|
endpoint = '{0}/createCA'.format(current_app.config.get('CLOUDCA_API_ENDPOINT'))
|
||||||
options['caDN']['email'] = options['ownerEmail']
|
options['caDN']['email'] = options['ownerEmail']
|
||||||
|
|
||||||
if options['caType'] == 'subca':
|
if options['caType'] == 'subca':
|
||||||
|
@ -239,8 +246,11 @@ class CloudCAIssuerPlugin(IssuerPlugin, CloudCA):
|
||||||
options['validityStart'] = convert_date_to_utc_time(options['validityStart']).isoformat()
|
options['validityStart'] = convert_date_to_utc_time(options['validityStart']).isoformat()
|
||||||
options['validityEnd'] = convert_date_to_utc_time(options['validityEnd']).isoformat()
|
options['validityEnd'] = convert_date_to_utc_time(options['validityEnd']).isoformat()
|
||||||
|
|
||||||
|
try:
|
||||||
response = self.session.post(self.url + endpoint, data=dumps(remove_none(options)), timeout=10,
|
response = self.session.post(self.url + endpoint, data=dumps(remove_none(options)), timeout=10,
|
||||||
verify=self.ca_bundle)
|
verify=self.ca_bundle)
|
||||||
|
except ConnectionError:
|
||||||
|
raise Exception("Could not communicate with CloudCA, is it up?")
|
||||||
|
|
||||||
json = process_response(response)
|
json = process_response(response)
|
||||||
roles = []
|
roles = []
|
||||||
|
@ -274,7 +284,7 @@ class CloudCAIssuerPlugin(IssuerPlugin, CloudCA):
|
||||||
:param csr:
|
:param csr:
|
||||||
:param options:
|
:param options:
|
||||||
"""
|
"""
|
||||||
endpoint = '{0}/enroll'.format(API_ENDPOINT)
|
endpoint = '{0}/enroll'.format(current_app.config.get('CLOUDCA_API_ENDPOINT'))
|
||||||
# lets default to two years if it's not specified
|
# lets default to two years if it's not specified
|
||||||
# we do some last minute data massaging
|
# we do some last minute data massaging
|
||||||
options = get_default_issuance(options)
|
options = get_default_issuance(options)
|
||||||
|
@ -330,7 +340,7 @@ class CloudCASourcePlugin(SourcePlugin, CloudCA):
|
||||||
:param cert_handle:
|
:param cert_handle:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
endpoint = '{0}/getCert'.format(API_ENDPOINT)
|
endpoint = '{0}/getCert'.format(current_app.config.get('CLOUDCA_API_ENDPOINT'))
|
||||||
response = self.session.post(self.url + endpoint, data=dumps({'caName': ca_name}), timeout=10,
|
response = self.session.post(self.url + endpoint, data=dumps({'caName': ca_name}), timeout=10,
|
||||||
verify=self.ca_bundle)
|
verify=self.ca_bundle)
|
||||||
raw = process_response(response)
|
raw = process_response(response)
|
||||||
|
|
Loading…
Reference in New Issue