def create(**kwargs): """ Creates a new certificate. """ from lemur.notifications import service as notification_service cert, private_key, cert_chain = mint(kwargs) cert.owner = kwargs['owner'] database.create(cert) cert.description = kwargs['description'] g.user.certificates.append(cert) database.update(g.user) # do this after the certificate has already been created because if it fails to upload to the third party # we do not want to lose the certificate information. database.update_list(cert, 'destinations', Destination, kwargs.get('destinations')) database.update_list(cert, 'replaces', Certificate, kwargs['replacements']) database.update_list(cert, 'notifications', Notification, kwargs.get('notifications')) # create default notifications for this certificate if none are provided notifications = cert.notifications if not kwargs.get('notifications'): notification_name = "DEFAULT_{0}".format(cert.owner.split('@')[0].upper()) notifications += notification_service.create_default_expiration_notifications(notification_name, [cert.owner]) notification_name = 'DEFAULT_SECURITY' notifications += notification_service.create_default_expiration_notifications(notification_name, current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')) cert.notifications = notifications database.update(cert) return cert
def create(**kwargs): """ Creates a new certificate. """ from lemur.notifications import service as notification_service cert, private_key, cert_chain = mint(kwargs) cert.owner = kwargs["owner"] database.create(cert) cert.description = kwargs["description"] g.user.certificates.append(cert) database.update(g.user) # do this after the certificate has already been created because if it fails to upload to the third party # we do not want to lose the certificate information. database.update_list(cert, "destinations", Destination, kwargs.get("destinations")) database.update_list(cert, "notifications", Notification, kwargs.get("notifications")) # create default notifications for this certificate if none are provided notifications = [] if not kwargs.get("notifications"): notification_name = "DEFAULT_{0}".format(cert.owner.split("@")[0].upper()) notifications += notification_service.create_default_expiration_notifications(notification_name, [cert.owner]) notification_name = "DEFAULT_SECURITY" notifications += notification_service.create_default_expiration_notifications( notification_name, current_app.config.get("LEMUR_SECURITY_TEAM_EMAIL") ) cert.notifications = notifications database.update(cert) return cert
def default_notification(self, data): if not data['notifications']: notification_name = "DEFAULT_{0}".format(data['owner'].split('@')[0].upper()) data['notifications'] += notification_service.create_default_expiration_notifications(notification_name, [data['owner']]) notification_name = 'DEFAULT_SECURITY' data['notifications'] += notification_service.create_default_expiration_notifications(notification_name, current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')) return data
def default_notifications(self, data): if not data['notifications']: notification_name = "DEFAULT_{0}".format(data['owner'].split('@')[0].upper()) data['notifications'] += notification_service.create_default_expiration_notifications(notification_name, [data['owner']]) notification_name = 'DEFAULT_SECURITY' data['notifications'] += notification_service.create_default_expiration_notifications(notification_name, current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')) return data
def run(self, password): create() user = user_service.get_by_username("lemur") if not user: if not password: sys.stdout.write( "We need to set Lemur's password to continue!\n") password = prompt_pass("Password") password1 = prompt_pass("Confirm Password") if password != password1: sys.stderr.write("[!] Passwords do not match!\n") sys.exit(1) role = role_service.get_by_name('admin') if role: sys.stdout.write( "[-] Admin role already created, skipping...!\n") else: # we create an admin role role = role_service.create( 'admin', description='this is the lemur administrator role') sys.stdout.write("[+] Created 'admin' role\n") user_service.create("lemur", password, 'lemur@nobody', True, None, [role]) sys.stdout.write( "[+] Added a 'lemur' user and added it to the 'admin' role!\n") else: sys.stdout.write( "[-] Default user has already been created, skipping...!\n") sys.stdout.write("[+] Creating expiration email notifications!\n") sys.stdout.write( "[!] Using {0} as specified by LEMUR_SECURITY_TEAM_EMAIL for notifications\n" .format("LEMUR_SECURITY_TEAM_EMAIL")) intervals = current_app.config.get( "LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", []) sys.stdout.write( "[!] Creating {num} notifications for {intervals} days as specified by LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS\n" .format(num=len(intervals), intervals=",".join([str(x) for x in intervals]))) recipients = current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL') notification_service.create_default_expiration_notifications( "DEFAULT_SECURITY", recipients=recipients) sys.stdout.write("[/] Done!\n")
def default_notification(self, data): if not data['notifications']: data['notifications'] += notification_service.create_default_expiration_notifications( "DEFAULT_{0}".format(data['owner'].split('@')[0].upper()), [data['owner']], ) data['notifications'] += notification_service.create_default_expiration_notifications( 'DEFAULT_SECURITY', current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL'), current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL_INTERVALS', None) ) return data
def default_notification(self, data): if not data["notifications"]: data[ "notifications"] += notification_service.create_default_expiration_notifications( "DEFAULT_{0}".format(data["owner"].split("@")[0].upper()), [data["owner"]], ) data[ "notifications"] += notification_service.create_default_expiration_notifications( "DEFAULT_SECURITY", current_app.config.get("LEMUR_SECURITY_TEAM_EMAIL"), current_app.config.get( "LEMUR_SECURITY_TEAM_EMAIL_INTERVALS", None), ) return data
def create(kwargs): """ Create a new authority. :return: """ issuer = plugins.get(kwargs.get('pluginName')) kwargs['creator'] = g.current_user.email cert_body, intermediate, issuer_roles = issuer.create_authority(kwargs) cert = Certificate(cert_body, chain=intermediate) cert.owner = kwargs['ownerEmail'] if kwargs['caType'] == 'subca': cert.description = "This is the ROOT certificate for the {0} sub certificate authority the parent \ authority is {1}.".format( kwargs.get('caName'), kwargs.get('caParent')) else: cert.description = "This is the ROOT certificate for the {0} certificate authority.".format( kwargs.get('caName')) cert.user = g.current_user cert.notifications = notification_service.create_default_expiration_notifications( 'DEFAULT_SECURITY', current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')) # we create and attach any roles that the issuer gives us role_objs = [] for r in issuer_roles: role = role_service.create( r['name'], password=r['password'], description="{0} auto generated role".format( kwargs.get('pluginName')), username=r['username']) # the user creating the authority should be able to administer it if role.username == 'admin': g.current_user.roles.append(role) role_objs.append(role) authority = Authority(kwargs.get('caName'), kwargs['ownerEmail'], kwargs['pluginName'], cert_body, description=kwargs['caDescription'], chain=intermediate, roles=role_objs) database.update(cert) authority = database.create(authority) g.current_user.authorities.append(authority) return authority
def update(cert_id, owner, description, active, destinations, notifications): """ Updates a certificate. :param cert_id: :param owner: :param active: :return: """ from lemur.notifications import service as notification_service cert = get(cert_id) cert.active = active cert.description = description # we might have to create new notifications if the owner changes new_notifications = [] # get existing names to remove notification_name = "DEFAULT_{0}".format(cert.owner.split("@")[0].upper()) for n in notifications: if notification_name not in n.label: new_notifications.append(n) notification_name = "DEFAULT_{0}".format(owner.split("@")[0].upper()) new_notifications += notification_service.create_default_expiration_notifications(notification_name, owner) cert.notifications = new_notifications database.update_list(cert, "destinations", Destination, destinations) cert.owner = owner return database.update(cert)
def import_certificate(**kwargs): """ Uploads already minted certificates and pulls the required information into Lemur. This is to be used for certificates that are created outside of Lemur but should still be tracked. Internally this is used to bootstrap Lemur with external certificates, and used when certificates are 'discovered' through various discovery techniques. was still in aws. :param kwargs: """ from lemur.users import service as user_service from lemur.notifications import service as notification_service cert = Certificate(kwargs['public_certificate'], chain=kwargs['intermediate_certificate']) # TODO future source plugins might have a better understanding of who the 'owner' is we should support this cert.owner = kwargs.get('owner', current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')[0]) cert.creator = kwargs.get('creator', user_service.get_by_email('lemur@nobody')) # NOTE existing certs may not follow our naming standard we will # overwrite the generated name with the actual cert name if kwargs.get('name'): cert.name = kwargs.get('name') if kwargs.get('user'): cert.user = kwargs.get('user') notification_name = 'DEFAULT_SECURITY' notifications = notification_service.create_default_expiration_notifications(notification_name, current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')) cert.notifications = notifications cert = database.create(cert) return cert
def enforce_notifications(self, data): """ Add default notification for current owner if none exist. This ensures that the default notifications are added in the event of owner change. Old owner notifications are retained unless explicitly removed later in the code path. :param data: :return: """ if data.get("owner"): notification_name = "DEFAULT_{0}".format( data["owner"].split("@")[0].upper() ) # Even if one default role exists, return # This allows a User to remove unwanted default notification for current owner if any(n.label.startswith(notification_name) for n in data["notifications"]): return data data[ "notifications" ] += notification_service.create_default_expiration_notifications( notification_name, [data["owner"]] ) return data
def run(self, password): create() user = user_service.get_by_username("lemur") if not user: if not password: sys.stdout.write("We need to set Lemur's password to continue!\n") password = prompt_pass("Password") password1 = prompt_pass("Confirm Password") if password != password1: sys.stderr.write("[!] Passwords do not match!\n") sys.exit(1) role = role_service.get_by_name("admin") if role: sys.stdout.write("[-] Admin role already created, skipping...!\n") else: # we create an admin role role = role_service.create("admin", description="this is the lemur administrator role") sys.stdout.write("[+] Created 'admin' role\n") user_service.create("lemur", password, "lemur@nobody", True, None, [role]) sys.stdout.write("[+] Added a 'lemur' user and added it to the 'admin' role!\n") else: sys.stdout.write("[-] Default user has already been created, skipping...!\n") sys.stdout.write("[+] Creating expiration email notifications!\n") sys.stdout.write( "[!] Using {0} as specified by LEMUR_SECURITY_TEAM_EMAIL for notifications\n".format( "LEMUR_SECURITY_TEAM_EMAIL" ) ) intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", []) sys.stdout.write( "[!] Creating {num} notifications for {intervals} days as specified by LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS\n".format( num=len(intervals), intervals=",".join([str(x) for x in intervals]) ) ) recipients = current_app.config.get("LEMUR_SECURITY_TEAM_EMAIL") notification_service.create_default_expiration_notifications("DEFAULT_SECURITY", recipients=recipients) sys.stdout.write("[/] Done!\n")
def upload(**kwargs): """ Allows for pre-made certificates to be imported into Lemur. """ from lemur.notifications import service as notification_service cert = Certificate( kwargs.get('public_cert'), kwargs.get('private_key'), kwargs.get('intermediate_cert'), ) # we override the generated name if one is provided if kwargs.get('name'): cert.name = kwargs['name'] cert.description = kwargs.get('description') cert.owner = kwargs['owner'] cert = database.create(cert) g.user.certificates.append(cert) database.update_list(cert, 'destinations', Destination, kwargs.get('destinations')) database.update_list(cert, 'notifications', Notification, kwargs.get('notifications')) database.update_list(cert, 'replaces', Certificate, kwargs['replacements']) # create default notifications for this certificate if none are provided notifications = [] if not kwargs.get('notifications'): notification_name = "DEFAULT_{0}".format( cert.owner.split('@')[0].upper()) notifications += notification_service.create_default_expiration_notifications( notification_name, [cert.owner]) notification_name = 'DEFAULT_SECURITY' notifications += notification_service.create_default_expiration_notifications( notification_name, current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')) cert.notifications = notifications database.update(cert) return cert
def create(kwargs): """ Create a new authority. :rtype : Authority :return: """ issuer = plugins.get(kwargs.get('pluginName')) kwargs['creator'] = g.current_user.email cert_body, intermediate, issuer_roles = issuer.create_authority(kwargs) cert = Certificate(cert_body, chain=intermediate) cert.owner = kwargs['ownerEmail'] cert.description = "This is the ROOT certificate for the {0} certificate authority".format(kwargs.get('caName')) cert.user = g.current_user cert.notifications = notification_service.create_default_expiration_notifications( 'DEFAULT_SECURITY', current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL') ) # we create and attach any roles that the issuer gives us role_objs = [] for r in issuer_roles: role = role_service.create( r['name'], password=r['password'], description="{0} auto generated role".format(kwargs.get('pluginName')), username=r['username']) # the user creating the authority should be able to administer it if role.username == 'admin': g.current_user.roles.append(role) role_objs.append(role) authority = Authority( kwargs.get('caName'), kwargs['ownerEmail'], kwargs['pluginName'], cert_body, description=kwargs['caDescription'], chain=intermediate, roles=role_objs ) database.update(cert) authority = database.create(authority) g.current_user.authorities.append(authority) return authority
def enforce_notifications(self, data): """ Ensures that when an owner changes, default notifications are added for the new owner. Old owner notifications are retained unless explicitly removed. :param data: :return: """ if data['owner']: notification_name = "DEFAULT_{0}".format(data['owner'].split('@')[0].upper()) data['notifications'] += notification_service.create_default_expiration_notifications(notification_name, [data['owner']]) return data
def create(**kwargs): """ Creates a new certificate. """ from lemur.notifications import service as notification_service cert, private_key, cert_chain = mint(kwargs) cert.owner = kwargs['owner'] # we override the generated name if one is provided if kwargs.get('name'): cert.name = kwargs['name'] database.create(cert) cert.description = kwargs.get('description') g.user.certificates.append(cert) database.update(g.user) # do this after the certificate has already been created because if it fails to upload to the third party # we do not want to lose the certificate information. database.update_list(cert, 'destinations', Destination, kwargs['destinations']) database.update_list(cert, 'replaces', Certificate, kwargs['replacements']) database.update_list(cert, 'notifications', Notification, kwargs['notifications']) # create default notifications for this certificate if none are provided notifications = cert.notifications if not kwargs.get('notifications'): notification_name = "DEFAULT_{0}".format(cert.owner.split('@')[0].upper()) notifications += notification_service.create_default_expiration_notifications(notification_name, [cert.owner]) notification_name = 'DEFAULT_SECURITY' notifications += notification_service.create_default_expiration_notifications(notification_name, current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')) cert.notifications = notifications database.update(cert) metrics.send('certificate_issued', 'counter', 1, metric_tags=dict(owner=cert.owner, issuer=cert.issuer)) return cert
def upload(**kwargs): """ Allows for pre-made certificates to be imported into Lemur. """ from lemur.notifications import service as notification_service cert = Certificate( kwargs.get('public_cert'), kwargs.get('private_key'), kwargs.get('intermediate_cert'), ) # we override the generated name if one is provided if kwargs.get('name'): cert.name = kwargs['name'] cert.description = kwargs.get('description') cert.owner = kwargs['owner'] cert = database.create(cert) g.user.certificates.append(cert) database.update_list(cert, 'destinations', Destination, kwargs['destinations']) database.update_list(cert, 'notifications', Notification, kwargs['notifications']) database.update_list(cert, 'replaces', Certificate, kwargs['replacements']) # create default notifications for this certificate if none are provided notifications = [] if not kwargs.get('notifications'): notification_name = "DEFAULT_{0}".format(cert.owner.split('@')[0].upper()) notifications += notification_service.create_default_expiration_notifications(notification_name, [cert.owner]) notification_name = 'DEFAULT_SECURITY' notifications += notification_service.create_default_expiration_notifications(notification_name, current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')) cert.notifications = notifications database.update(cert) return cert
def upload(**kwargs): """ Allows for pre-made certificates to be imported into Lemur. """ from lemur.notifications import service as notification_service cert = Certificate(kwargs.get("public_cert"), kwargs.get("private_key"), kwargs.get("intermediate_cert")) # we override the generated name if one is provided if kwargs.get("name"): cert.name = kwargs["name"] cert.description = kwargs.get("description") cert.owner = kwargs["owner"] cert = database.create(cert) g.user.certificates.append(cert) database.update_list(cert, "destinations", Destination, kwargs.get("destinations")) database.update_list(cert, "notifications", Notification, kwargs.get("notifications")) # create default notifications for this certificate if none are provided notifications = [] if not kwargs.get("notifications"): notification_name = "DEFAULT_{0}".format(cert.owner.split("@")[0].upper()) notifications += notification_service.create_default_expiration_notifications(notification_name, [cert.owner]) notification_name = "DEFAULT_SECURITY" notifications += notification_service.create_default_expiration_notifications( notification_name, current_app.config.get("LEMUR_SECURITY_TEAM_EMAIL") ) cert.notifications = notifications database.update(cert) return cert
def import_certificate(**kwargs): """ Uploads already minted certificates and pulls the required information into Lemur. This is to be used for certificates that are created outside of Lemur but should still be tracked. Internally this is used to bootstrap Lemur with external certificates, and used when certificates are 'discovered' through various discovery techniques. was still in aws. :param kwargs: """ from lemur.users import service as user_service from lemur.notifications import service as notification_service cert = Certificate(kwargs['public_certificate'], chain=kwargs['intermediate_certificate']) # TODO future source plugins might have a better understanding of who the 'owner' is we should support this cert.owner = kwargs.get( 'owner', current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')[0]) cert.creator = kwargs.get('creator', user_service.get_by_email('lemur@nobody')) # NOTE existing certs may not follow our naming standard we will # overwrite the generated name with the actual cert name if kwargs.get('name'): cert.name = kwargs.get('name') if kwargs.get('user'): cert.user = kwargs.get('user') notification_name = 'DEFAULT_SECURITY' notifications = notification_service.create_default_expiration_notifications( notification_name, current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')) if kwargs.get('replacements'): database.update_list(cert, 'replaces', Certificate, kwargs['replacements']) cert.notifications = notifications cert = database.create(cert) return cert
def update(cert_id, owner, description, active, destinations, notifications, replaces): """ Updates a certificate :param cert_id: :param owner: :param description: :param active: :param destinations: :param notifications: :param replaces: :return: """ from lemur.notifications import service as notification_service cert = get(cert_id) cert.active = active cert.description = description # we might have to create new notifications if the owner changes new_notifications = [] # get existing names to remove notification_name = "DEFAULT_{0}".format(cert.owner.split('@')[0].upper()) for n in notifications: if notification_name not in n.label: new_notifications.append(n) notification_name = "DEFAULT_{0}".format(owner.split('@')[0].upper()) new_notifications += notification_service.create_default_expiration_notifications( notification_name, owner) cert.notifications = new_notifications database.update_list(cert, 'destinations', Destination, destinations) database.update_list(cert, 'replaces', Certificate, replaces) cert.owner = owner return database.update(cert)
def create(kwargs): """ Create a new authority. :return: """ issuer = kwargs['plugin']['plugin_object'] kwargs['creator'] = g.current_user.email cert_body, intermediate, issuer_roles = issuer.create_authority(kwargs) cert = Certificate(cert_body, chain=intermediate) cert.owner = kwargs['owner'] if kwargs['type'] == 'subca': cert.description = "This is the ROOT certificate for the {0} sub certificate authority the parent \ authority is {1}.".format(kwargs.get('name'), kwargs.get('parent')) else: cert.description = "This is the ROOT certificate for the {0} certificate authority.".format( kwargs.get('name') ) cert.user = g.current_user cert.notifications = notification_service.create_default_expiration_notifications( 'DEFAULT_SECURITY', current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL') ) # we create and attach any roles that the issuer gives us role_objs = [] for r in issuer_roles: role = role_service.create( r['name'], password=r['password'], description="{0} auto generated role".format(issuer.title), username=r['username']) # the user creating the authority should be able to administer it if role.username == 'admin': g.current_user.roles.append(role) role_objs.append(role) authority = Authority( kwargs.get('name'), kwargs['owner'], issuer.slug, cert_body, description=kwargs['description'], chain=intermediate, roles=role_objs ) database.update(cert) authority = database.create(authority) # the owning dl or role should have this authority associated with it owner_role = role_service.get_by_name(kwargs['owner']) if not owner_role: owner_role = role_service.create(kwargs['owner']) owner_role.authority = authority g.current_user.authorities.append(authority) return authority
def run(self, password): create() user = user_service.get_by_username("lemur") admin_role = role_service.get_by_name("admin") if admin_role: sys.stdout.write("[-] Admin role already created, skipping...!\n") else: # we create an admin role admin_role = role_service.create( "admin", description="This is the Lemur administrator role.") sys.stdout.write("[+] Created 'admin' role\n") operator_role = role_service.get_by_name("operator") if operator_role: sys.stdout.write( "[-] Operator role already created, skipping...!\n") else: # we create an operator role operator_role = role_service.create( "operator", description="This is the Lemur operator role.") sys.stdout.write("[+] Created 'operator' role\n") read_only_role = role_service.get_by_name("read-only") if read_only_role: sys.stdout.write( "[-] Read only role already created, skipping...!\n") else: # we create an read only role read_only_role = role_service.create( "read-only", description="This is the Lemur read only role.") sys.stdout.write("[+] Created 'read-only' role\n") if not user: if not password: sys.stdout.write( "We need to set Lemur's password to continue!\n") password = prompt_pass("Password") password1 = prompt_pass("Confirm Password") if password != password1: sys.stderr.write("[!] Passwords do not match!\n") sys.exit(1) user_service.create("lemur", password, "*****@*****.**", True, None, [admin_role]) sys.stdout.write( "[+] Created the user 'lemur' and granted it the 'admin' role!\n" ) else: sys.stdout.write( "[-] Default user has already been created, skipping...!\n") intervals = current_app.config.get( "LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", []) sys.stdout.write( "[!] Creating {num} notifications for {intervals} days as specified by LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS\n" .format(num=len(intervals), intervals=",".join([str(x) for x in intervals]))) recipients = current_app.config.get("LEMUR_SECURITY_TEAM_EMAIL") sys.stdout.write("[+] Creating expiration email notifications!\n") sys.stdout.write( "[!] Using {0} as specified by LEMUR_SECURITY_TEAM_EMAIL for notifications\n" .format(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) sys.stdout.write( "[+] Creating default certificate rotation policy of {days} days before issuance.\n" .format(days=days)) policy_service.create(days=days, name=_DEFAULT_ROTATION_INTERVAL) sys.stdout.write("[/] Done!\n")
def run(self, password): create() user = user_service.get_by_username("lemur") admin_role = role_service.get_by_name('admin') if admin_role: sys.stdout.write("[-] Admin role already created, skipping...!\n") else: # we create an admin role admin_role = role_service.create('admin', description='This is the Lemur administrator role.') sys.stdout.write("[+] Created 'admin' role\n") operator_role = role_service.get_by_name('operator') if operator_role: sys.stdout.write("[-] Operator role already created, skipping...!\n") else: # we create an operator role operator_role = role_service.create('operator', description='This is the Lemur operator role.') sys.stdout.write("[+] Created 'operator' role\n") read_only_role = role_service.get_by_name('read-only') if read_only_role: sys.stdout.write("[-] Read only role already created, skipping...!\n") else: # we create an read only role read_only_role = role_service.create('read-only', description='This is the Lemur read only role.') sys.stdout.write("[+] Created 'read-only' role\n") if not user: if not password: sys.stdout.write("We need to set Lemur's password to continue!\n") password = prompt_pass("Password") password1 = prompt_pass("Confirm Password") if password != password1: sys.stderr.write("[!] Passwords do not match!\n") sys.exit(1) user_service.create("lemur", password, '*****@*****.**', True, None, [admin_role]) sys.stdout.write("[+] Created the user 'lemur' and granted it the 'admin' role!\n") else: sys.stdout.write("[-] Default user has already been created, skipping...!\n") intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS", []) sys.stdout.write( "[!] Creating {num} notifications for {intervals} days as specified by LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS\n".format( num=len(intervals), intervals=",".join([str(x) for x in intervals]) ) ) recipients = current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL') sys.stdout.write("[+] Creating expiration email notifications!\n") sys.stdout.write("[!] Using {0} as specified by LEMUR_SECURITY_TEAM_EMAIL for notifications\n".format(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) sys.stdout.write("[+] Creating default certificate rotation policy of {days} days before issuance.\n".format( days=days)) policy_service.create(days=days, name=_DEFAULT_ROTATION_INTERVAL) sys.stdout.write("[/] Done!\n")