Merge pull request #14 from kevgliss/master

A few misc fixes found during testing.
This commit is contained in:
kevgliss 2015-07-02 14:14:49 -07:00
commit 92a3c1a5a0
5 changed files with 63 additions and 35 deletions

View File

@ -100,6 +100,10 @@ used by Lemur to help associate certificates that do not currently have an owner
Lemur has discovered certificates from a third party resource. This is also a default user that can be used to Lemur has discovered certificates from a third party resource. This is also a default user that can be used to
administer Lemur. administer Lemur.
.. code-block:: bash
$ lemur db init
.. code-block:: bash .. code-block:: bash
$ lemur init $ lemur init

View File

@ -62,8 +62,3 @@ def configure_hook(app):
response.status_code = 403 response.status_code = 403
return response return response

24
lemur/default.conf.py Normal file
View File

@ -0,0 +1,24 @@
# This is just Python which means you can inherit and tweak settings
import os
_basedir = os.path.abspath(os.path.dirname(__file__))
ADMINS = frozenset([''])
THREADS_PER_PAGE = 8
#############
## General ##
#############
# These will need to be set to `True` if you are developing locally
CORS = False
debug = False
#############
## Logging ##
#############
LOG_LEVEL = "DEBUG"
LOG_FILE = "lemur.log"

View File

@ -94,11 +94,11 @@ def configure_app(app, config=None):
except RuntimeError: except RuntimeError:
if config and config != 'None': if config and config != 'None':
app.config.from_object(from_file(config)) app.config.from_object(from_file(config))
else: elif os.path.isfile(os.path.expanduser("~/.lemur/lemur.conf.py")):
app.config.from_object(from_file(os.path.expanduser("~/.lemur/lemur.conf.py"))) app.config.from_object(from_file(os.path.expanduser("~/.lemur/lemur.conf.py")))
else:
app.config.from_object(from_file(os.path.join(os.getcwd(), 'default.conf.py')))
if not app.config.get('ENCRYPTION_KEY'):
raise NoEncryptionKeyFound
def configure_extensions(app): def configure_extensions(app):

59
lemur/manage.py Normal file → Executable file
View File

@ -333,14 +333,15 @@ class InitializeApp(Command):
else: else:
sys.stdout.write("[-] Default user has already been created, skipping...!\n") sys.stdout.write("[-] Default user has already been created, skipping...!\n")
for account_name, account_number in current_app.config.get('AWS_ACCOUNT_MAPPINGS').items(): if current_app.app.config.get('AWS_ACCOUNT_MAPPINGS'):
account = account_service.get_by_account_number(account_number) for account_name, account_number in current_app.config.get('AWS_ACCOUNT_MAPPINGS').items():
account = account_service.get_by_account_number(account_number)
if not account: if not account:
account_service.create(account_number, label=account_name) account_service.create(account_number, label=account_name)
sys.stdout.write("[+] Added new account {0}:{1}!\n".format(account_number, account_name)) sys.stdout.write("[+] Added new account {0}:{1}!\n".format(account_number, account_name))
else: else:
sys.stdout.write("[-] Account already exists, skipping...!\n") sys.stdout.write("[-] Account already exists, skipping...!\n")
sys.stdout.write("[/] Done!\n") sys.stdout.write("[/] Done!\n")
@ -439,26 +440,6 @@ class CreateRole(Command):
sys.stdout.write("[+] Created new role: {0}".format(name)) sys.stdout.write("[+] Created new role: {0}".format(name))
@manager.command
def create_config(config_path=None):
"""
Creates a new configuration file if one does not already exist
"""
if not config_path:
config_path = DEFAULT_CONFIG_PATH
config_path = os.path.expanduser(config_path)
dir = os.path.dirname(config_path)
if not os.path.exists(dir):
os.makedirs(dir)
config = generate_settings()
with open(config_path, 'w') as f:
f.write(config)
sys.stdout.write("Created a new configuration file {0}\n".format(config_path))
class LemurServer(Command): class LemurServer(Command):
""" """
This is the main Lemur server, it runs the flask app with gunicorn and This is the main Lemur server, it runs the flask app with gunicorn and
@ -494,6 +475,26 @@ class LemurServer(Command):
return app.run() return app.run()
@manager.command
def create_config(config_path=None):
"""
Creates a new configuration file if one does not already exist
"""
if not config_path:
config_path = DEFAULT_CONFIG_PATH
config_path = os.path.expanduser(config_path)
dir = os.path.dirname(config_path)
if not os.path.exists(dir):
os.makedirs(dir)
config = generate_settings()
with open(config_path, 'w') as f:
f.write(config)
sys.stdout.write("Created a new configuration file {0}\n".format(config_path))
def main(): def main():
manager.add_command("start", LemurServer()) manager.add_command("start", LemurServer())
manager.add_command("runserver", Server(host='127.0.0.1')) manager.add_command("runserver", Server(host='127.0.0.1'))
@ -505,3 +506,7 @@ def main():
manager.add_command('create_role', CreateRole()) manager.add_command('create_role', CreateRole())
manager.add_command("sync", Sync()) manager.add_command("sync", Sync())
manager.run() manager.run()
if __name__ == "__main__":
main()