Ejemplo n.º 1
0
def populate_conf_directory():
    cork = Cork("example_conf", initialize=True)

    cork._store.roles["admin"] = 100
    cork._store.roles["editor"] = 60
    cork._store.roles["user"] = 50
    cork._store.save_roles()

    tstamp = str(datetime.utcnow())
    username = password = "******"
    cork._store.users[username] = {
        "role": "admin",
        "hash": cork._hash(username, password),
        "email_addr": username + "@localhost.local",
        "desc": username + " test user",
        "creation_date": tstamp,
    }
    username = password = ""
    cork._store.users[username] = {
        "role": "user",
        "hash": cork._hash(username, password),
        "email_addr": username + "@localhost.local",
        "desc": username + " test user",
        "creation_date": tstamp,
    }
    cork._store.save_users()
Ejemplo n.º 2
0
def populate_conf_directory():
    cork = Cork('example_conf', initialize=True)

    cork._store.roles['admin'] = 100
    cork._store.roles['editor'] = 60
    cork._store.roles['user'] = 50
    cork._store._savejson('roles', cork._store.roles)

    tstamp = str(datetime.utcnow())
    username = password = '******'
    cork._store.users[username] = {
        'role': 'admin',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    username = password = ''
    cork._store.users[username] = {
        'role': 'user',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    cork._store._save_users()
Ejemplo n.º 3
0
def populate_conf_directory(adminpass):
    print("Setting screenly admin pw to "+str(adminpass))
    if not os.path.exists("/home/pi/screenly.auth"):
        os.mkdir("/home/pi/screenly.auth")
    
    cork = Cork('/home/pi/screenly.auth', initialize=True)

    cork._store.roles['admin'] = 100
    cork._store.roles['editor'] = 60
    cork._store.save_roles()

    tstamp = str(datetime.utcnow()) 
    username = '******'
    password=adminpass
    
    cork._store.users[username] = {
        'role': 'admin',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    username = password = '******'
    cork._store.users[username] = {
        'role': 'user',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    cork._store.save_users()
Ejemplo n.º 4
0
def populate_conf_directory():
    cork = Cork('users', initialize=True)

    cork._store.roles['admin'] = 100
    cork._store.roles['editor'] = 60
    cork._store.roles['user'] = 50
    cork._store.save_roles()

    tstamp = str(datetime.utcnow())
    username = password = '******'
    cork._store.users[username] = {
        'role': 'admin',
        'hash': cork._hash(username, password),
        'email_addr': username + '@gmail.com',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    username = password = '******'
    cork._store.users[username] = {
        'role': 'user',
        'hash': cork._hash(username, password),
        'email_addr': username + '@usaid.gov',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    cork._store.save_users()
Ejemplo n.º 5
0
def populate_conf_directory():
    cork = Cork('cork_conf', initialize=True)

    cork._store.roles['admin'] = 100
    cork._store.roles['user'] = 50
    cork._store.save_roles()

    tstamp = str(datetime.utcnow())
    username = password = '******'
    cork._store.users[username] = {
        'role': 'admin',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    username = password = '******'
    cork._store.users[username] = {
        'role': 'user',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    cork._store.save_users()
Ejemplo n.º 6
0
def run(*args):
    #cork (app auth)
    client = pymongo.MongoClient(app_settings.DATABASE_URI)
    db = client[app_settings.DATABASE_CORK]
    db.authenticate(app_settings.DATABASE_USERNAME,
                    app_settings.DATABASE_PASSWORD, app_settings.DATABASE_MAIN)
    existing = db.users.find_one({"login": "******"})
    if existing:
        return

    mb = MongoDBBackend(db_name=app_settings.DATABASE_CORK,
                        username=app_settings.DATABASE_USERNAME,
                        password=app_settings.DATABASE_PASSWORD,
                        authdb=app_settings.DATABASE_MAIN,
                        initialize=True)
    cork = Cork(backend=mb, preferred_hashing_algorithm='scrypt')
    admin_hash = cork._hash("admin", app_settings.ADMIN_PASSWORD)
    mb.users._coll.insert({
        "login": "******",
        "email_addr": "*****@*****.**",
        "desc": "admin user",
        "role": "admin",
        "hash": admin_hash,
        "creation_date": "2012-10-28 20:50:26.286723"
    })
    mb.roles._coll.insert({'role': 'admin', 'val': 100})
    #mb.roles._coll.insert({'role': 'editor', 'val': 60})
    mb.roles._coll.insert({'role': 'user', 'val': 50})
Ejemplo n.º 7
0
def populate_conf_directory(out_dir, non_interactive):
    cork = Cork(out_dir, initialize=True)

    cork._store.roles['admin'] = 101
    cork._store.roles['portal'] = 100
    cork._store.roles['experimenter'] = 60
    cork._store.save_roles()

    tstamp = str(datetime.utcnow())
    stop = False
    while not stop:
        if non_interactive:
            choice = 'y'
            stop = True
        else:
            choice = input('do you want to add one user? [Y/n]')
        if choice.lower() == 'y' or choice.lower() == 'yes' or not choice:

            username, password, role = get_username_and_password(
                non_interactive)
            user_cork = {
                'role': role,
                'hash': cork._hash(username, password),
                'email_addr': username + '@localhost.local',
                'desc': username + ' test user',
                'creation_date': tstamp
            }
            cork._store.users[username] = user_cork
            print("Cork user is: %s, password is %s" % (username, password))
        else:
            stop = True

    cork._store.save_users()
Ejemplo n.º 8
0
    def populate_conf_directory(self, auth_dir):
        """
        Creation of basic auth files.
        """
        logger.info("Creating new authentication files, check STDOUT for the generated admin password.")
        cork = Cork(auth_dir, initialize=True)

        cork._store.roles['admin'] = 100
        cork._store.roles['access_all'] = 70
        cork._store.roles['access_normalized'] = 60
        cork._store.roles['public'] = 10
        cork._store.save_roles()

        tstamp = str(datetime.utcnow())

        #default admin combo: admin/admin
        username = '******'
        password = str(uuid.uuid4())
        cork._store.users[username] = {
            'role': 'admin',
            'hash': cork._hash(username, password),
            'email_addr': username + '@localhost.local',
            'desc': 'Default administrative account',
            'creation_date': tstamp
        }
        cork._store.save_users()
        #for security reasons we fdo not want this in the log files.
        print "A 'admin' account has been created with the password '{0}'".format(password)

        return cork
Ejemplo n.º 9
0
def setup_dir(testdir):
    """Setup test directory with valid JSON files"""

    #dummy users for testing
    users = {
        'admin': {
            'role': 'admin'
        },
        'a_all': {
            'role': 'access_all'
        },
        'a_norm': {
            'role': 'access_normalized'
        },
        'public': {
            'role': 'public'
        }
    }

    #set hash for all users
    for k, v in users.items():
        v['hash'] = Cork._hash(k, 'password')

    with open("%s/users.json" % testdir, 'w') as f:
        f.write(json.dumps(users))
    with open("%s/roles.json" % testdir, 'w') as f:
        f.write(
            """{"admin": 100, "access_all": 70, "access_normalized": 60,"public": 10}"""
        )
    with open("%s/register.json" % testdir, 'w') as f:
        f.write("""{}""")
def change_pass(pwd):
    sqlalchemy_backend = Cork(backend=SqlAlchemyBackend(config.db_url))
    metadata = MetaData()
    engine = create_engine(config.db_url)
    metadata.bind = engine
    users = Table("users", metadata, extend_existing=True,
                  autoload=True, autoload_with=engine)
    users.update().where(users.c.username == "transito").values(
        hash=sqlalchemy_backend._hash("transito", pwd)).execute()
Ejemplo n.º 11
0
def change_pass(pwd):
    sqlalchemy_backend = Cork(backend=SqlAlchemyBackend(config.db_url))
    metadata = MetaData()
    engine = create_engine(config.db_url)
    metadata.bind = engine
    users = Table("users",
                  metadata,
                  extend_existing=True,
                  autoload=True,
                  autoload_with=engine)
    users.update().where(users.c.username == "transito").values(
        hash=sqlalchemy_backend._hash("transito", pwd)).execute()
Ejemplo n.º 12
0
    def populate_conf_directory(self):
        """Populate a directory with valid configuration files, to be run just once
        The files are not modified by each test
        """
        self._tmpdir = os.path.join(self._tmproot,
                                    "cork_functional_test_source")

        # only do this once, as advertised
        if os.path.exists(self._tmpdir):
            return

        os.mkdir(self._tmpdir)
        os.mkdir(self._tmpdir + "/example_conf")

        cork = Cork(os.path.join(self._tmpdir, "example_conf"),
                    initialize=True)

        cork._store.roles['admin'] = 100
        cork._store.roles['editor'] = 60
        cork._store.roles['user'] = 50
        cork._store.save_roles()

        tstamp = str(datetime.utcnow())
        username = password = '******'
        cork._store.users[username] = {
            'role': 'admin',
            'hash': cork._hash(username, password),
            'email_addr': username + '@localhost.local',
            'desc': username + ' test user',
            'creation_date': tstamp
        }
        username = password = ''
        cork._store.users[username] = {
            'role': 'user',
            'hash': cork._hash(username, password),
            'email_addr': username + '@localhost.local',
            'desc': username + ' test user',
            'creation_date': tstamp
        }
        cork._store.save_users()
Ejemplo n.º 13
0
    def populate_conf_directory(self):
        """Populate a directory with valid configuration files, to be run just once
        The files are not modified by each test
        """
        self._tmpdir = os.path.join(self._tmproot,
                                    "cork_functional_test_source")

        # only do this once, as advertised
        if os.path.exists(self._tmpdir):
            return

        os.mkdir(self._tmpdir)
        os.mkdir(self._tmpdir + "/example_conf")

        cork = Cork(os.path.join(self._tmpdir, "example_conf"),
                    initialize=True)

        cork._store.roles["admin"] = 100
        cork._store.roles["editor"] = 60
        cork._store.roles["user"] = 50
        cork._store.save_roles()

        tstamp = str(datetime.utcnow())
        username = password = "******"
        cork._store.users[username] = {
            "role": "admin",
            "hash": cork._hash(username, password),
            "email_addr": username + "@localhost.local",
            "desc": username + " test user",
            "creation_date": tstamp,
        }
        username = password = ""
        cork._store.users[username] = {
            "role": "user",
            "hash": cork._hash(username, password),
            "email_addr": username + "@localhost.local",
            "desc": username + " test user",
            "creation_date": tstamp,
        }
        cork._store.save_users()
def add_user(Base, session):
    Users = Base.classes.users
    sqlalchemy_backend = Cork(backend=SqlAlchemyBackend(config.db_url))
    session.add(
        Users(username="******",
              role="admin",
              hash=sqlalchemy_backend._hash("transito", "transito"),
              email_addr="*****@*****.**",
              desc="operario",
              creation_date=str(datetime.now()),
              last_login=str(datetime.now())))
    session.commit()
    session.close()
Ejemplo n.º 15
0
def populate_conf_directory():
    """Populate a directory with valid configuration files, to be run just once
    The files are not modified by each test
    """
    global tmpdir
    tmpdir = "%s/cork_functional_test_source" % tmproot

    # only do this once, as advertised
    if os.path.exists(tmpdir):
        return

    os.mkdir(tmpdir)
    os.mkdir(tmpdir + "/example_conf")

    cork = Cork(tmpdir + "/example_conf", initialize=True)

    cork._store.roles["admin"] = 100
    cork._store.roles["editor"] = 60
    cork._store.roles["user"] = 50
    cork._store._savejson("roles", cork._store.roles)

    tstamp = str(datetime.utcnow())
    username = password = "******"
    cork._store.users[username] = {
        "role": "admin",
        "hash": cork._hash(username, password),
        "email_addr": username + "@localhost.local",
        "desc": username + " test user",
        "creation_date": tstamp,
    }
    username = password = ""
    cork._store.users[username] = {
        "role": "user",
        "hash": cork._hash(username, password),
        "email_addr": username + "@localhost.local",
        "desc": username + " test user",
        "creation_date": tstamp,
    }
    cork._store._save_users()
Ejemplo n.º 16
0
def populate_conf_directory():
    """Populate a directory with valid configuration files, to be run just once
    The files are not modified by each test
    """
    global tmpdir
    tmpdir = "%s/cork_functional_test_source" % tmproot

    # only do this once, as advertised
    if os.path.exists(tmpdir): return

    os.mkdir(tmpdir)
    os.mkdir(tmpdir + "/example_conf")

    cork = Cork(tmpdir + "/example_conf", initialize=True)

    cork._store.roles['admin'] = 100
    cork._store.roles['editor'] = 60
    cork._store.roles['user'] = 50
    cork._store._savejson('roles', cork._store.roles)

    tstamp = str(datetime.utcnow())
    username = password = '******'
    cork._store.users[username] = {
        'role': 'admin',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    username = password = ''
    cork._store.users[username] = {
        'role': 'user',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    cork._store._save_users()
Ejemplo n.º 17
0
def __initialize_cork_user(username, role, password):
    cork = Cork(directory=get_config("api", "cork-files-path",
                                     "/etc/softfire/users"),
                initialize=False)
    user_cork = {
        'role': role,
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': '{:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now())
    }
    cork._store.users[username] = user_cork
    cork._store.save_users()
    logger.debug('Created cork user {} with role {}.'.format(username, role))
def add_user(Base, session):
    Users = Base.classes.users
    sqlalchemy_backend = Cork(backend=SqlAlchemyBackend(config.db_url))
    session.add(
        Users(
            username="******",
            role="admin",
            hash=sqlalchemy_backend._hash("transito", "transito"),
            email_addr="*****@*****.**",
            desc="operario",
            creation_date=str(datetime.now()),
            last_login=str(datetime.now()),
        )
    )
    session.commit()
    session.close()
Ejemplo n.º 19
0
def populate_conf_directory():
    cork = Cork('conf', initialize=True)

    cork._store.roles['admin'] = 100
    cork._store.roles['user'] = 50
    cork._store.save_roles()

    tstamp = str(datetime.utcnow())
    username = password = '******'
    cork._store.users[username] = {
        'role': 'admin',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    cork._store.save_users()
    print("Login with the username '{}' and the password '{}'. Then go to /admin, add a new admin, and delete this one.".format(username, password))
Ejemplo n.º 20
0
def create_test_databases(*args):
    create_databases_with_auth(app_settings.DATABASE_CORK)
    create_databases_with_auth(app_settings.DATABASE_MAIN)
    mb = MongoDBBackend(db_name=app_settings.DATABASE_CORK,
                        username=app_settings.DATABASE_USERNAME,
                        password=app_settings.DATABASE_PASSWORD,
                        authdb=app_settings.DATABASE_MAIN,
                        initialize=True)
    cork = Cork(backend=mb, preferred_hashing_algorithm='scrypt')
    testuser_hash = cork._hash("testuser", "testuser")
    mb.users._coll.insert({
        "login": "******",
        "email_addr": "*****@*****.**",
        "desc": "test user",
        "role": "user",
        "hash": testuser_hash,
        "creation_date": "2012-10-28 20:50:26.286723"
    })
Ejemplo n.º 21
0
def create_test_users():
    """Run from the 'src' folder"""
    cork = Cork('config', initialize=True)

    cork._store.roles['admin'] = 100
    cork._store.roles['edit'] = 50
    cork._store.save_roles()

    tstamp = str(datetime.utcnow())
    username = '******'
    password = '******'
    cork._store.users[username] = {
        'role': 'admin',
        'hash': cork._hash(username, password),
        'email_addr': username + '@localhost.local',
        'desc': username + ' test user',
        'creation_date': tstamp
    }
    cork._store.save_users()
Ejemplo n.º 22
0
def populate_conf_directory():
    cork = Cork('.', initialize=True)

    cork._store.roles['admin'] = 100
    cork._store._savejson('roles', cork._store.roles)

    tstamp = str(datetime.utcnow())
    username = ""
    while not username:
        username = raw_input("Enter admin username: "******""
    while not password:
        password = raw_input("Enter admin password: ") 
        
    cork._store.users[username] = {
        'role': 'admin',
        'hash': cork._hash(username, password),
        'creation_date': tstamp
    }
    cork._store._save_users()
Ejemplo n.º 23
0
def populate_conf_directory():
    cork = Cork('.', initialize=True)

    cork._store.roles['admin'] = 100
    cork._store._savejson('roles', cork._store.roles)

    tstamp = str(datetime.utcnow())
    username = ""
    while not username:
        username = raw_input("Enter admin username: "******""
    while not password:
        password = raw_input("Enter admin password: ")

    cork._store.users[username] = {
        'role': 'admin',
        'hash': cork._hash(username, password),
        'creation_date': tstamp
    }
    cork._store._save_users()
Ejemplo n.º 24
0
def setup_dir(testdir):
    """Setup test directory with valid JSON files"""

    # dummy users for testing
    users = {
        "admin": {"role": "admin"},
        "a_all": {"role": "access_all"},
        "a_norm": {"role": "access_normalized"},
        "public": {"role": "public"},
    }

    # set hash for all users
    for k, v in users.items():
        v["hash"] = Cork._hash(k, "password")

    with open("%s/users.json" % testdir, "w") as f:
        f.write(json.dumps(users))
    with open("%s/roles.json" % testdir, "w") as f:
        f.write("""{"admin": 100, "access_all": 70, "access_normalized": 60,"public": 10}""")
    with open("%s/register.json" % testdir, "w") as f:
        f.write("""{}""")
Ejemplo n.º 25
0
def main():
    global aaa
    global app
    global content_path

    setproctitle("shoebill")

    args = parse_args()

    site_path = os.path.abspath(args.directory)
    content_path = os.path.join(site_path, "content")
    check_site_dir(site_path, content_path)

    print("Starting Shoebill...")
    setup_git_repo(site_path)

    if not args.no_auth:
        # Setup authentication
        if not aaa_available:
            print(
                """Error: the Beaker and/or Cork libraries are missing. \
            \nPlease install them or disable authentication using --no-auth"""
            )
            sys.exit(1)

        auth_dir = os.path.join(site_path, ".shoebill_auth")
        if not os.path.isdir(auth_dir):
            print("Creating authentication data")
            os.mkdir(auth_dir)

            token = gen_random_token(21)
            with open(os.path.join(auth_dir, "token"), "w") as f:
                f.write(token)

            aaa = Cork(auth_dir, initialize=True, preferred_hashing_algorithm="scrypt")
            aaa._store.roles["admin"] = 100
            aaa._store.roles["editor"] = 50
            aaa._store.save_roles()
            tstamp = str(datetime.utcnow())
            admin_password = gen_random_token(6)
            aaa._store.users["admin"] = {
                "role": "admin",
                "hash": aaa._hash("admin", admin_password),
                "email_addr": "",
                "desc": "admin",
                "creation_date": tstamp,
                "_accessed_time": tstamp,
                "last_login": tstamp,
            }
            aaa._store.save_users()
            print("\n", "*" * 32, "\n")
            print("Initialized user 'admin' with password '%s'" % admin_password)
            print("\n", "*" * 32, "\n")

        else:
            aaa = Cork(auth_dir, preferred_hashing_algorithm="scrypt")

    if aaa:
        # Sessions are enabled only if authentication is enabled
        with open(os.path.join(auth_dir, "token")) as f:
            session_encrypt_key = f.read()

        session_opts = {
            "session.cookie_expires": True,
            "session.encrypt_key": session_encrypt_key,
            "session.httponly": True,
            "session.timeout": 3600 * 24,  # 1 day
            "session.type": "cookie",
            "session.validate_key": True,
        }
        wrapped_app = SessionMiddleware(app, session_opts)
        bottle.run(
            wrapped_app,
            host=args.host,
            port=args.port,
            debug=args.debug,
            reloader=args.debug,
            server="auto",
        )

    else:
        bottle.run(
            app,
            host=args.host,
            port=args.port,
            debug=args.debug,
            reloader=args.debug,
            server="auto",
        )
Ejemplo n.º 26
0
from datetime import datetime
from cork import Cork
from pathlib import Path

password = '******'

confdir = Path('./authconf')
if not confdir.exists():
    confdir.mkdir()

cork = Cork('authconf', initialize=True)

cork._store.roles['admin'] = 100
cork._store.save_roles()

tstamp = str(datetime.utcnow())
username = '******'
cork._store.users[username] = {
    'role': 'admin',
    'hash': cork._hash(username, password),
    'email_addr': f'{username}@localhost.local',
    'desc': '',
    'creation_date': tstamp
}
cork._store.save_users()
Ejemplo n.º 27
0
from cork import Cork
from datetime import datetime

aaa = Cork('auth')
username = '******'
password = '******'
tstamp = str(datetime.utcnow())
aaa._store.users[username] = {
    'role': 'admin',
    'hash': aaa._hash(username, password),
    'email_addr': username + '@localhost.local',
    'desc': username + ' test user',
    'creation_date': tstamp
}
aaa._store.save_users()
Ejemplo n.º 28
0
import sys
import os
from datetime import datetime
from cork import Cork

try:
    os.mkdir("authconf")
except OSError:
    pass

cork = Cork("authconf", initialize=True)
cork._store.roles["user"] = 50
cork._store.save_roles()

username = sys.argv[1]
password = sys.argv[2]

cork._store.users[username] = {
    "role": "user",
    "hash": cork._hash(username, password),
    "email_addr": "",
    "desc": "",
    "creation_date": str(datetime.utcnow()),
}
cork._store.save_users()
print "Generated directory %s%sauthconf" % (os.getcwd(), os.sep)
Ejemplo n.º 29
0
def main():
    global aaa
    global app
    global content_path

    setproctitle('shoebill')

    args = parse_args()

    site_path = os.path.abspath(args.directory)
    content_path = os.path.join(site_path, 'content')
    check_site_dir(site_path, content_path)

    print "Starting Shoebill..."
    setup_git_repo(site_path)

    if not args.no_auth:
        # Setup authentication
        if not aaa_available:
            print """Error: the Beaker and/or Cork libraries are missing. \
            \nPlease install them or disable authentication using --no-auth"""
            sys.exit(1)

        auth_dir = os.path.join(site_path, '.shoebill_auth')
        if not os.path.isdir(auth_dir):
            print "Creating authentication data"
            os.mkdir(auth_dir)

            token = gen_random_token(21)
            with open(os.path.join(auth_dir, 'token'), 'w') as f:
                f.write(token)

            aaa = Cork(auth_dir, initialize=True)
            aaa._store.roles['admin'] = 100
            aaa._store.roles['editor'] = 50
            aaa._store.save_roles()
            tstamp = str(datetime.utcnow())
            admin_password = gen_random_token(6)
            aaa._store.users['admin'] = {
                'role': 'admin',
                'hash': aaa._hash('admin', admin_password),
                'email_addr': '',
                'desc': 'admin',
                'creation_date': tstamp,
                '_accessed_time': tstamp,
                'last_login': tstamp
            }
            aaa._store.save_users()
            print "\n", "*" * 32, "\n"
            print "Initialized user 'admin' with password '%s'" % admin_password
            print "\n", "*" * 32, "\n"

        else:
            aaa = Cork(auth_dir)


    if aaa:
        # Sessions are enabled only if authentication is enabled
        with open(os.path.join(auth_dir, 'token')) as f:
            session_encrypt_key = f.read()

        session_opts = {
            'session.cookie_expires': True,
            'session.encrypt_key': session_encrypt_key,
            'session.httponly': True,
            'session.timeout': 3600 * 24,  # 1 day
            'session.type': 'cookie',
            'session.validate_key': True,
        }
        wrapped_app = SessionMiddleware(app, session_opts)
        bottle.run(wrapped_app, host=args.host, port=args.port, debug=args.debug,
            reloader=args.debug, server='auto')

    else:
        bottle.run(app, host=args.host, port=args.port, debug=args.debug,
            reloader=args.debug, server='auto')