|
@ -199,11 +199,15 @@ def checkCookie(request): |
|
|
@app.before_request |
|
|
@app.before_request |
|
|
def before_request(): |
|
|
def before_request(): |
|
|
g.db = connect_db() |
|
|
g.db = connect_db() |
|
|
|
|
|
if request.path != "/sso" and (not checkCookie(request)): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.after_request |
|
|
@app.after_request |
|
|
def after_request(response): |
|
|
def after_request(response): |
|
|
|
|
|
if g.db != None: |
|
|
g.db.close() |
|
|
g.db.close() |
|
|
|
|
|
g.db = None |
|
|
return response |
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -232,122 +236,78 @@ def do_sso(request): |
|
|
# 登录 |
|
|
# 登录 |
|
|
@app.route('/login', methods=['GET', 'POST']) |
|
|
@app.route('/login', methods=['GET', 'POST']) |
|
|
def login(): |
|
|
def login(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_login(request) |
|
|
return do_login(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 主页 |
|
|
# 主页 |
|
|
@app.route('/', methods=['GET', 'POST']) |
|
|
@app.route('/', methods=['GET', 'POST']) |
|
|
def index(): |
|
|
def index(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return render_template("index.html") |
|
|
return render_template("index.html") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 控制 |
|
|
# 控制 |
|
|
@app.route('/jump/hosts', methods=['GET', 'POST']) |
|
|
@app.route('/jump/hosts', methods=['GET', 'POST']) |
|
|
def hostlist(): |
|
|
def hostlist(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_hostlist(request) |
|
|
return do_hostlist(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/users', methods=['GET', 'POST']) |
|
|
@app.route('/jump/users', methods=['GET', 'POST']) |
|
|
def userlist(): |
|
|
def userlist(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_userlist(request) |
|
|
return do_userlist(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/user/add', methods=['GET', 'POST']) |
|
|
@app.route('/jump/user/add', methods=['GET', 'POST']) |
|
|
def add_user(): |
|
|
def add_user(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_add_user(request) |
|
|
return do_add_user(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/user/del', methods=['GET', 'POST']) |
|
|
@app.route('/jump/user/del', methods=['GET', 'POST']) |
|
|
def del_user(): |
|
|
def del_user(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_del_user(request) |
|
|
return do_del_user(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/user/sudo', methods=['GET', 'POST']) |
|
|
|
|
|
def sudo_user(): |
|
|
|
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_sudo_user(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/user/unsudo', methods=['GET', 'POST']) |
|
|
|
|
|
def unsudo_user(): |
|
|
|
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_unsudo_user(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/user/modify', methods=['GET', 'POST']) |
|
|
@app.route('/jump/user/modify', methods=['GET', 'POST']) |
|
|
def modify_user(): |
|
|
def modify_user(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_modify_user(request) |
|
|
return do_modify_user(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/user/hosts', methods=['GET', 'POST']) |
|
|
@app.route('/jump/user/hosts', methods=['GET', 'POST']) |
|
|
def userhostlist(): |
|
|
def userhostlist(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_userhostlist(request) |
|
|
return do_userhostlist(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/host/add', methods=['GET', 'POST']) |
|
|
@app.route('/jump/host/add', methods=['GET', 'POST']) |
|
|
def add_host(): |
|
|
def add_host(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_add_host(request) |
|
|
return do_add_host(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/host/del', methods=['GET', 'POST']) |
|
|
@app.route('/jump/host/del', methods=['GET', 'POST']) |
|
|
def del_host(): |
|
|
def del_host(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_del_host(request) |
|
|
return do_del_host(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/host/adduser', methods=['GET', 'POST']) |
|
|
@app.route('/jump/host/adduser', methods=['GET', 'POST']) |
|
|
def host_adduser(): |
|
|
def host_adduser(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_host_adduser(request) |
|
|
return do_host_adduser(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/host/deluser', methods=['GET', 'POST']) |
|
|
@app.route('/jump/host/deluser', methods=['GET', 'POST']) |
|
|
def host_deluser(): |
|
|
def host_deluser(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_host_deluser(request) |
|
|
return do_host_deluser(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/host/modifyuser', methods=['GET', 'POST']) |
|
|
@app.route('/jump/host/modifyuser', methods=['GET', 'POST']) |
|
|
def host_modifyuser(): |
|
|
def host_modifyuser(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_host_modifyuser(request) |
|
|
return do_host_modifyuser(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/host/users', methods=['GET', 'POST']) |
|
|
@app.route('/jump/host/users', methods=['GET', 'POST']) |
|
|
def hostuserlist(): |
|
|
def hostuserlist(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_hostuserlist(request) |
|
|
return do_hostuserlist(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/jump/hostuser', methods=['GET', 'POST']) |
|
|
@app.route('/jump/hostuser', methods=['GET', 'POST']) |
|
|
def hostuser(): |
|
|
def hostuser(): |
|
|
if not checkCookie(request): |
|
|
|
|
|
return redirect_sso() |
|
|
|
|
|
return do_hostuserall(request) |
|
|
return do_hostuserall(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|