Exemplo n.º 1
0
def post_admin_keys_add(session):
    db = get_db()
    name = request.forms.get("name")
    data = request.forms.get("data")
    if not is_empty(name) and not is_empty(data):
        public_key = PublicKey(name, data, session["username"])
        db.add(public_key)
        db.commit()
        ssh.write_auth_file(ssh.compute_path(), db.query(User).all())
    return redirect("/admin/keys")
Exemplo n.º 2
0
def get_admin_keys_delete(session, keyname):
    db = get_db()
    (db.query(PublicKey).filter(PublicKey.name == keyname, PublicKey.user_name == session["username"]).delete())
    db.commit()
    ssh.write_auth_file(ssh.compute_path(), db.query(User).all())
    return redirect("/admin/keys")