Пример #1
0
def create_database():
    if not authenticator.is_authenticated():
        return redirect(url_for('sign_in'))

    database = request.form['name']
    users = request.form['users']

    assert isinstance(users, unicode)

    users = users.split(':')

    assert isinstance(users, list)

    try:
        mymanage.create_database(database, session['username'])
    except:
        return jsonify(success=False)

    # grant privileges to users
    try:
        for user in users:
            mymanage.grant_privileges(user, database)
    except:
        return jsonify(success=False)

    return jsonify(success=True)
Пример #2
0
def overview_users():
    if not authenticator.is_authenticated():
        return redirect(url_for('sign_in'))

    users = mymanage.get_users_by_user(session['username'])

    return render_template('overview_users.html', users=users)
Пример #3
0
def delete_database():
    if not authenticator.is_authenticated():
        return redirect(url_for('sign_in'))

    database = request.form['name']

    try:
        mymanage.drop_database(database, session['username'])
    except:
        return jsonify(success=False)

    return jsonify(success=True)
Пример #4
0
def overview():
    if not authenticator.is_authenticated():
        return redirect(url_for('sign_in'))

    databases = mymanage.get_databases_by_user(session['username'])
    users = mymanage.get_users_by_user(session['username'])

    database_size = {}

    for database in databases:
        database_size[database.name] = mymanage.get_database_size(database.name)

    return render_template('overview.html', databases=databases, sizes=database_size, users=users)
Пример #5
0
def create_user():
    if not authenticator.is_authenticated():
        return redirect(url_for('sign_in'))

    username = request.form['name']
    password = request.form['password']

    try:
        mymanage.create_user(username, password, session['username'])
    except:
        return jsonify(success=False)

    return jsonify(success=True)
Пример #6
0
def get_provisioning():
    if not authenticator.is_authenticated():
        return redirect(url_for('sign_in'))

    database = request.form['name']

    provisioned_users = mymanage.get_privileges_by_database(database)

    result = list()

    for user in provisioned_users:
        result.append(user.name)

    return jsonify(users=result)
Пример #7
0
def save_provisioning():
    if not authenticator.is_authenticated():
        return redirect(url_for('sign_in'))

    database = request.form['name']
    users = request.form['users']
    users = users.split(':')

    provisioned_users = mymanage.get_privileges_by_database(database)
    provisioned_users = map(lambda(e): e.name, provisioned_users)

    deprovision_users = set(provisioned_users)-set(users)
    provision_users = set(users)-set(provisioned_users)

    for user in deprovision_users:
        mymanage.revoke_privileges(user, database)

    for user in provision_users:
        mymanage.grant_privileges(user, database)

    return jsonify(success=True)