Exemplo n.º 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)
Exemplo n.º 2
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)