Check for default rotation policy before updating db (#1223)
This commit is contained in:
parent
91500d1022
commit
3e5db9eedb
|
@ -251,12 +251,17 @@ class InitializeApp(Command):
|
||||||
recipients = current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')
|
recipients = current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')
|
||||||
notification_service.create_default_expiration_notifications("DEFAULT_SECURITY", recipients=recipients)
|
notification_service.create_default_expiration_notifications("DEFAULT_SECURITY", recipients=recipients)
|
||||||
|
|
||||||
|
_DEFAULT_ROTATION_INTERVAL = 'default'
|
||||||
|
default_rotation_interval = policy_service.get_by_name(_DEFAULT_ROTATION_INTERVAL)
|
||||||
|
|
||||||
|
if default_rotation_interval:
|
||||||
|
sys.stdout.write("[-] Default rotation interval policy already created, skipping...!\n")
|
||||||
|
else:
|
||||||
days = current_app.config.get("LEMUR_DEFAULT_ROTATION_INTERVAL", 30)
|
days = current_app.config.get("LEMUR_DEFAULT_ROTATION_INTERVAL", 30)
|
||||||
sys.stdout.write("[+] Creating default certificate rotation policy of {days} days before issuance.\n".format(
|
sys.stdout.write("[+] Creating default certificate rotation policy of {days} days before issuance.\n".format(
|
||||||
days=days
|
days=days))
|
||||||
))
|
policy_service.create(days=days, name=_DEFAULT_ROTATION_INTERVAL)
|
||||||
|
|
||||||
policy_service.create(days=days, name='default')
|
|
||||||
sys.stdout.write("[/] Done!\n")
|
sys.stdout.write("[/] Done!\n")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,15 @@ def get(policy_id):
|
||||||
return database.get(RotationPolicy, policy_id)
|
return database.get(RotationPolicy, policy_id)
|
||||||
|
|
||||||
|
|
||||||
|
def get_by_name(policy_name):
|
||||||
|
"""
|
||||||
|
Retrieves policy by its name.
|
||||||
|
:param policy_name:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return database.get_all(RotationPolicy, policy_name, field='name').all()
|
||||||
|
|
||||||
|
|
||||||
def delete(policy_id):
|
def delete(policy_id):
|
||||||
"""
|
"""
|
||||||
Delete a rotation policy.
|
Delete a rotation policy.
|
||||||
|
|
Loading…
Reference in New Issue