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