From 5f9c3f168d495cf81fbd39fb300748c5c923506e Mon Sep 17 00:00:00 2001 From: root <krish94@uab.edu> Date: Tue, 5 Apr 2022 13:02:39 -0500 Subject: [PATCH 01/30] added state checking --- app/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index 7753b03..5dd8c41 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -34,6 +34,8 @@ def create_app(config_name): @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page def index(): + invalid_state = ["blocked", "certification"] + if 'uid' not in session: session['uid']=str(uuid.uuid4()) @@ -48,7 +50,11 @@ def create_app(config_name): else: session['return_url'] = request.referrer - return render_template('auth/SignUp.html', room_id=session['uid'], + if rc_util.check_state(session['user'].get('username')) in invalid_state: + return render_template('errors/error.html', title='account creation failed') + + else: + return render_template('auth/SignUp.html', room_id=session['uid'], username=session['user'].get('username'), fullname=session['user'].get('fullname'), email=session['user'].get('email'), referrer=session['return_url'], cancel_url=vars.default_referrer, -- GitLab From 91b50d6b2e669cf5d6249ba787e9bbd500bbd79a Mon Sep 17 00:00:00 2001 From: root <krish94@uab.edu> Date: Tue, 5 Apr 2022 22:44:54 -0500 Subject: [PATCH 02/30] 1. Reading eppa value from request header 2. Sending to error page of eppa not valid --- app/__init__.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 5dd8c41..ab5b673 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -12,6 +12,7 @@ from flask_bootstrap import Bootstrap import random import os import json +import sys def create_app(config_name): app = Flask(__name__, static_folder='static') # initialization of the flask app @@ -22,11 +23,13 @@ def create_app(config_name): username_key = list(filter(lambda key: (request.headers.get(key) is not None), vars.username_key)) fullname_key = list(filter(lambda key: (request.headers.get(key) is not None), vars.fullname_key)) email_key = list(filter(lambda key: (request.headers.get(key) is not None), vars.email_key)) + eppa_key = list(filter(lambda key: (request.headers.get(key) is not None), vars.eppa_key)) user = { "username": (request.headers.get(username_key[0]) if len(username_key) > 0 else None), "fullname": (request.headers.get(fullname_key[0]) if len(fullname_key) > 0 else None), "email": (request.headers.get(email_key[0]) if len(email_key) > 0 else None), + "eppa": (request.headers.get(eppa_key[0]) if len(eppa_key) > 0 else None), } return user @@ -34,6 +37,7 @@ def create_app(config_name): @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page def index(): + valid_eppa = ["staff", "faculty", "student"] invalid_state = ["blocked", "certification"] if 'uid' not in session: @@ -42,16 +46,14 @@ def create_app(config_name): if 'user' not in session: session["user"] = get_authorized_user() - if "redir" in request.args and 'return_url' not in session: # check for redir arg in url - session['return_url'] = request.args.get("redir") + session['return_url'] = request.args.get('redir', vars.default_referrer) - elif "redir" not in request.args and 'return_url' not in session: - session['return_url'] = vars.default_referrer - else: - session['return_url'] = request.referrer + + if session['user'].get('eppa') in not valid_eppa: + return render_template('errors/error.html', title='shibboleth error') if rc_util.check_state(session['user'].get('username')) in invalid_state: - return render_template('errors/error.html', title='account creation failed') + return render_template('errors/error.html', title='account state error') else: return render_template('auth/SignUp.html', room_id=session['uid'], @@ -62,6 +64,8 @@ def create_app(config_name): cancel_msg=messages.cancel_message, error_msg=messages.error_message) + + @app.route('/error_account') def error_account_create(): return render_template('errors/error.html', title='account creation failed') -- GitLab From 691bf52b5f8fb02057e04098fe00e66cd31ab29e Mon Sep 17 00:00:00 2001 From: root <krish94@uab.edu> Date: Tue, 5 Apr 2022 22:59:14 -0500 Subject: [PATCH 03/30] fixed typo in if condition --- app/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index ab5b673..15af932 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -49,7 +49,7 @@ def create_app(config_name): session['return_url'] = request.args.get('redir', vars.default_referrer) - if session['user'].get('eppa') in not valid_eppa: + if session['user'].get('eppa') not in valid_eppa: return render_template('errors/error.html', title='shibboleth error') if rc_util.check_state(session['user'].get('username')) in invalid_state: -- GitLab From bd5461123f7559ce76158e92101d47510ee806be Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Thu, 7 Apr 2022 21:31:54 -0500 Subject: [PATCH 04/30] added 2 pages for error handling --- app/__init__.py | 17 +++--- app/templates/errors/blocked.html | 74 ++++++++++++++++++++++++ app/templates/errors/certification.html | 75 +++++++++++++++++++++++++ 3 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 app/templates/errors/blocked.html create mode 100644 app/templates/errors/certification.html diff --git a/app/__init__.py b/app/__init__.py index 15af932..288b971 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -37,7 +37,7 @@ def create_app(config_name): @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page def index(): - valid_eppa = ["staff", "faculty", "student"] + invalid_eppa = ["staff"] invalid_state = ["blocked", "certification"] if 'uid' not in session: @@ -49,11 +49,11 @@ def create_app(config_name): session['return_url'] = request.args.get('redir', vars.default_referrer) - if session['user'].get('eppa') not in valid_eppa: - return render_template('errors/error.html', title='shibboleth error') + if session['user'].get('eppa') not in invalid_eppa: + return render_template('errors/blocked.html', title='shibboleth error') - if rc_util.check_state(session['user'].get('username')) in invalid_state: - return render_template('errors/error.html', title='account state error') +# if rc_util.check_state(session['user'].get('username')) in invalid_state: +# return render_template('errors/error.html', title='account state error') else: return render_template('auth/SignUp.html', room_id=session['uid'], @@ -66,10 +66,13 @@ def create_app(config_name): - @app.route('/error_account') + @app.route('/blocked_account') def error_account_create(): - return render_template('errors/error.html', title='account creation failed') + return render_template('errors/blocked.html') + @app.route('/certify_account') + def error_account_create(): + return render_template('errors/certification.html') # misc page error catching @app.errorhandler(403) diff --git a/app/templates/errors/blocked.html b/app/templates/errors/blocked.html new file mode 100644 index 0000000..964235e --- /dev/null +++ b/app/templates/errors/blocked.html @@ -0,0 +1,74 @@ +<html class="gr__rc_uab_edu"> +<title>User Blocked </title> +<head> +<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script> +<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> +<script src="{{ url_for('static', filename='scripts/function.js') }}"></script> + + +<link rel="shortcut icon" type="image/x-icon" href="/public/favicon.ico"> +<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/application.css') }}"> +<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/app2.css') }}"> + +<meta name="viewport" content="width=device-width, initial-scale=1"> +<style> + .navbar-inverse { background-color: rgb(0,99,65); } + button{ margin: 13px; + .important { color: #336699; }} +</style> + +</head> + + +<body data-gr-c-s-loaded="true"> +<header> + <nav class="navbar navbar-inverse navbar-static-top"> + <div class="container-fluid"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> + <a class="navbar-brand" href="/"> UAB Research Computing</a> + </div> + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9"> + <div class="navbar-right"> + <ul class="nav navbar-nav"> + <li> + <a target="_blank" href="https://docs.uabgrid.uab.edu/wiki/Cheaha_GettingStarted"> + <i class="fas fa-info-circle fa-fw"></i> Online Documentation + </a> + </li> + </ul> + </div> + </div> + </div> + </nav> +</header> + +<div class="container content" role="main" style="width: 100%"> + <div class="col-md-2 col-sm-2 my-col"> + <img alt="logo" height="auto" width="80%" src="{{ url_for('static', filename='img/logo_svg.svg') }}"> + <a href="https://tinyurl.com/cheahaAL" target="_blank"></a> + </div> + + <div class="col-md-10 col-sm-10 my-col"> + <div id="form-wrapper"> + <h2> Account blocked </h2> + <p style="font-size:110%;"> {{ welcome_msg |safe }}</p> + </div> + </div> +</div> + +<footer> + <div class="container-fluid"> + <div class="row"> + <div class="col-md-6 col-sm-6"> + <a href="https://osc.github.io/Open-OnDemand/"> + <img class="footer-logo" alt="Powered by Open OnDemand" height="40" style="margin-bottom: 20px" src="{{ url_for('static', filename='img/OpenOnDemand_powered_by_RGB-cb3aad5ff5350c7994f250fb334ddcc72e343233ce99eb71fda93beddd76a847.svg') }}"> + </a> + </div> + </div> + </div> +</footer> + +</body> +</html> diff --git a/app/templates/errors/certification.html b/app/templates/errors/certification.html new file mode 100644 index 0000000..529b7c7 --- /dev/null +++ b/app/templates/errors/certification.html @@ -0,0 +1,75 @@ +<html class="gr__rc_uab_edu"> +<title>User Certification Needed </title> +<head> +<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script> +<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> +<script src="{{ url_for('static', filename='scripts/function.js') }}"></script> + + +<link rel="shortcut icon" type="image/x-icon" href="/public/favicon.ico"> +<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/application.css') }}"> +<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/app2.css') }}"> + +<meta name="viewport" content="width=device-width, initial-scale=1"> +<style> + .navbar-inverse { background-color: rgb(0,99,65); } + button{ margin: 13px; + .important { color: #336699; }} +</style> + +</head> + + +<body data-gr-c-s-loaded="true"> +<header> + <nav class="navbar navbar-inverse navbar-static-top"> + <div class="container-fluid"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> + <a class="navbar-brand" href="/"> UAB Research Computing</a> + </div> + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9"> + <div class="navbar-right"> + <ul class="nav navbar-nav"> + <li> + <a target="_blank" href="https://docs.uabgrid.uab.edu/wiki/Cheaha_GettingStarted"> + <i class="fas fa-info-circle fa-fw"></i> Online Documentation + </a> + </li> + </ul> + </div> + </div> + </div> + </nav> +</header> + +<div class="container content" role="main" style="width: 100%"> + <div class="col-md-2 col-sm-2 my-col"> + <img alt="logo" height="auto" width="80%" src="{{ url_for('static', filename='img/logo_svg.svg') }}"> + <a href="https://tinyurl.com/cheahaAL" target="_blank"></a> + </div> + + <div class="col-md-10 col-sm-10 my-col"> + <div id="form-wrapper"> + <h2> Account/User Certification Needed </h2> + <p style="font-size:110%;"> {{ welcome_msg |safe }}</p> + <button class="btn btn-primary btn-md" id="submit" name="submit" type="button" value="Submit" onclick="accountCertification()"> Certify Account</button> + </div> + </div> +</div> + +<footer> + <div class="container-fluid"> + <div class="row"> + <div class="col-md-6 col-sm-6"> + <a href="https://osc.github.io/Open-OnDemand/"> + <img class="footer-logo" alt="Powered by Open OnDemand" height="40" style="margin-bottom: 20px" src="{{ url_for('static', filename='img/OpenOnDemand_powered_by_RGB-cb3aad5ff5350c7994f250fb334ddcc72e343233ce99eb71fda93beddd76a847.svg') }}"> + </a> + </div> + </div> + </div> +</footer> + +</body> +</html> -- GitLab From fadb4415f14c068cb6ace614a9c0ebb2298a15e8 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Thu, 7 Apr 2022 22:21:56 -0500 Subject: [PATCH 05/30] implemented logic to route user to correct page based on account state --- app/__init__.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 288b971..7a3e061 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -14,6 +14,9 @@ import os import json import sys +sys.path.append(vars.rabbitmq_agents_loc) +import rc_util + def create_app(config_name): app = Flask(__name__, static_folder='static') # initialization of the flask app cors = CORS(app, resources={r"/*": {"origins": vars.cors_allowed_origins}}) @@ -38,7 +41,6 @@ def create_app(config_name): def index(): invalid_eppa = ["staff"] - invalid_state = ["blocked", "certification"] if 'uid' not in session: session['uid']=str(uuid.uuid4()) @@ -49,11 +51,14 @@ def create_app(config_name): session['return_url'] = request.args.get('redir', vars.default_referrer) - if session['user'].get('eppa') not in invalid_eppa: - return render_template('errors/blocked.html', title='shibboleth error') +# if session['user'].get('eppa') not in invalid_eppa: +# return render_template('errors/blocked.html', title='shibboleth error') + + if rc_util.check_state(session['user'].get('username')) == "blocked": + return render_template('errors/blocked.html') -# if rc_util.check_state(session['user'].get('username')) in invalid_state: -# return render_template('errors/error.html', title='account state error') + elif rc_util.check_state(session['user'].get('username')) == "certification": + return render_template('errors/certification.html') else: return render_template('auth/SignUp.html', room_id=session['uid'], @@ -65,13 +70,12 @@ def create_app(config_name): error_msg=messages.error_message) - @app.route('/blocked_account') - def error_account_create(): + def account_block(): return render_template('errors/blocked.html') @app.route('/certify_account') - def error_account_create(): + def error_certify(): return render_template('errors/certification.html') # misc page error catching -- GitLab From 0015478320171fbefd6cdfaf043f076b64287f0c Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 11 Apr 2022 15:23:42 -0500 Subject: [PATCH 06/30] merge auto-conflict on app/__init__.py --- app/__init__.py | 9 +++++++-- app/static/scripts/function.js | 8 ++++++++ run.py | 11 +++++++++++ tasks.py | 18 +++++++++++++++++- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 7a3e061..dffb23c 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -58,8 +58,13 @@ def create_app(config_name): return render_template('errors/blocked.html') elif rc_util.check_state(session['user'].get('username')) == "certification": - return render_template('errors/certification.html') - + return render_template('errors/certify.html', room_id=session['uid'], + username=session['user'].get('username'), + fullname=session['user'].get('fullname'), email=session['user'].get('email'), + referrer=session['return_url'], cancel_url=vars.default_referrer, + welcome_msg=messages.welcome_message, + cancel_msg=messages.cancel_message, + error_msg=messages.error_message) else: return render_template('auth/SignUp.html', room_id=session['uid'], username=session['user'].get('username'), diff --git a/app/static/scripts/function.js b/app/static/scripts/function.js index ae406d7..8848dae 100644 --- a/app/static/scripts/function.js +++ b/app/static/scripts/function.js @@ -16,6 +16,14 @@ function request_account() { }) } +function certify_account() { + socket.emit('request certification', { + fullname: document.getElementById("fullname").value, + email: document.getElementById("email").value, + username: document.getElementById("username").value + }) +} + function renderDom(title, message, error_msg) { document.getElementById("form-wrapper").innerHTML = "<h3>" + title + "</h3><br>"; document.getElementById("form-wrapper").innerHTML += "<p>" + message + "</p><br>"; diff --git a/run.py b/run.py index f69a208..d68af76 100644 --- a/run.py +++ b/run.py @@ -35,5 +35,16 @@ def request_account(json, methods=['GET', 'POST']): print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in account creation: ", e) socketio.emit("Account creation failed", room) +@socketio.on('request certification') +def certify_account(json, methods=['GET', 'POST']): + print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tQueue request received: ' + str(json)) + room = str(session['uid']) + print("CERTIFY Room: {}".format(room)) + try: + tasks.celery_certify_account(json, session=room ) + except Exception as e: + print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in account certification: ", e) + socketio.emit("Account certification failed", room) + if __name__ == '__main__': socketio.run(app, host='0.0.0.0') diff --git a/tasks.py b/tasks.py index acf3818..5721e47 100644 --- a/tasks.py +++ b/tasks.py @@ -59,4 +59,20 @@ def celery_create_account(json, session): rc_util.add_account(username, queuename, email, fullname, reason) print('sent account info') print('Waiting for completion...') - rc_util.consume(queuename, routing_key=f'complete.{queuename}', callback=gen_f(room)) + rc_util.consume(queuename, routing_key=f'complete.{queuename}', callback=gen_f(room)) + +@celery.task +def celery_certify_account(json, session): + room = session + username= json['username'] + email= json['email'] + fullname= json['fullname'] + queuename= rc_util.encode_name(username) + + print("CERTIFY : "+time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue') + send_msg('certifying account', room) + print(username) + rc_util.update_state(username, 'ok') + print('sent account info') + print('Waiting for certification...') + send_msg('certified', room) -- GitLab From 57810eae6b6a4f1eaa61a216186848eac3af33e0 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 11 Apr 2022 15:28:00 -0500 Subject: [PATCH 07/30] added certify account page --- app/templates/errors/certify.html | 147 ++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 app/templates/errors/certify.html diff --git a/app/templates/errors/certify.html b/app/templates/errors/certify.html new file mode 100644 index 0000000..3102717 --- /dev/null +++ b/app/templates/errors/certify.html @@ -0,0 +1,147 @@ +<html class="gr__rc_uab_edu"> +<title>User Certification </title> +<head> +<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script> +<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> +<script src="{{ url_for('static', filename='scripts/function.js') }}"></script> + +<script> + console.info('Room ID: {{ room_id }}'); + var socket = io.connect(); + + socket.on( 'connect', function() { + autofill_form("{{ username }}", "{{ fullname }}", "{{ email }}"); + socket.emit( 'join_room', { + referrer: '{{ referrer }}' + }); + + socket.on( 'certifying account', function( msg ) { + displayloading2(); + }); + + socket.on( 'certified', function( msg ) { + $('#myModal2').modal('hide'); + window.location.replace('{{ referrer }}'); + }); + + socket.on( 'account error', function( msg ) { + console.log(msg); + $('#myModal2').modal('hide'); + renderDom("Account Create Error", "{{ error_msg }}", msg); + }); + + }); +</script> + +<link rel="shortcut icon" type="image/x-icon" href="/public/favicon.ico"> +<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/application.css') }}"> +<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/app2.css') }}"> + +<meta name="viewport" content="width=device-width, initial-scale=1"> +<style> + .navbar-inverse { background-color: rgb(0,99,65); } + button{ margin: 13px; + .important { color: #336699; }} +</style> + +</head> + + +<body data-gr-c-s-loaded="true"> +<header> + <nav class="navbar navbar-inverse navbar-static-top"> + <div class="container-fluid"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> + <a class="navbar-brand" href="/"> UAB Research Computing</a> + </div> + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9"> + <div class="navbar-right"> + <ul class="nav navbar-nav"> + <li> + <a target="_blank" href="https://docs.uabgrid.uab.edu/wiki/Cheaha_GettingStarted"> + <i class="fas fa-info-circle fa-fw"></i> Online Documentation + </a> + </li> + </ul> + </div> + </div> + </div> + </nav> +</header> + +<div class="container content" role="main" style="width: 100%"> + <div class="col-md-2 col-sm-2 my-col"> + <img alt="logo" height="auto" width="80%" src="{{ url_for('static', filename='img/logo_svg.svg') }}"> + <a href="https://tinyurl.com/cheahaAL" target="_blank"></a> + </div> + + <div class="col-md-10 col-sm-10 my-col"> + <div id="form-wrapper"> + <h2> Self Certification Form </h2> + <p style="font-size:110%;"> {{ welcome_msg |safe }}</p> + <div id="user-input"> + <form id="signup" data-toggle="validator" role="form" action="." method="post" onsubmit=""> + <div class="col-md-7 col-sm-7 my-col"> + <label for="username" class="control-label">Blazer Id:</label>	<input id="username" class="form-control" placeholder="Enter Username" required><br> + </div> + <div class="col-md-7 col-sm-7 my-col"> + <label for="fullname" class="control-label">Full Name:</label>	<input id="fullname" class="form-control" placeholder="Enter Full Name" required><br> + </div> + <div class="col-md-7 col-sm-7 my-col"> + <label for="email" class="control-label">Email:</label>	<input id="email" class="form-control" placeholder="Enter Email" required><br> + </div> + <br> + <div class="col-md-7 col-sm-7 my-col"> + <button class="btn btn-danger btn-md" id="cancel" name="cancel" type="button" onClick="renderDom('Account Creation Cancelled','{{ cancel_msg |safe }}', null)">Cancel</button> + <button class="btn btn-primary btn-md" id="submit" name="submit" type="button" value="Submit" onclick="displayloading1();certify_account()"> Certify Account</button> + </div> + </form> + </div> + </div> + </div> +</div> + +<div class="modal fade" id="overlayModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static" data-keyboard="false"> + <div class="modal-dialog modal-sm" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title" id="myModalLabel">Account Certification Request Received!</h4> + </div> + <div class="modal-body"> + <span>Communicating this information to the server</span> + <img src="{{ url_for('static', filename='img/loading.gif') }}" width="40px"> + </div> + </div> + </div> +</div> + +<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static" data-keyboard="false"> + <div class="modal-dialog modal-sm" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title" id="myModalLabel">Account Certification Received!</h4> + </div> + <div class="modal-body"> + <span>Please wait while we create your account. This may take up to 5-10 minutes.</span> + <img src="{{ url_for('static', filename='img/loading.gif') }}" width="40px"> + </div> + </div> + </div> +</div> + +<footer> + <div class="container-fluid"> + <div class="row"> + <div class="col-md-6 col-sm-6"> + <a href="https://osc.github.io/Open-OnDemand/"> + <img class="footer-logo" alt="Powered by Open OnDemand" height="40" style="margin-bottom: 20px" src="{{ url_for('static', filename='img/OpenOnDemand_powered_by_RGB-cb3aad5ff5350c7994f250fb334ddcc72e343233ce99eb71fda93beddd76a847.svg') }}"> + </a> + </div> + </div> + </div> +</footer> + +</body> +</html> -- GitLab From 4666180f1e997999d1c510f0cc1c60fa57b694da Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 11 Apr 2022 15:32:43 -0500 Subject: [PATCH 08/30] removed unused code for rc_util import --- app/__init__.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index dffb23c..7cec40b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -12,10 +12,6 @@ from flask_bootstrap import Bootstrap import random import os import json -import sys - -sys.path.append(vars.rabbitmq_agents_loc) -import rc_util def create_app(config_name): app = Flask(__name__, static_folder='static') # initialization of the flask app -- GitLab From 878865a2081ec80c207b71e61064d8508ba8c571 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Tue, 12 Apr 2022 10:24:50 -0500 Subject: [PATCH 09/30] edited modal message --- app/templates/errors/certify.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/errors/certify.html b/app/templates/errors/certify.html index 3102717..231acb2 100644 --- a/app/templates/errors/certify.html +++ b/app/templates/errors/certify.html @@ -124,7 +124,7 @@ <h4 class="modal-title" id="myModalLabel">Account Certification Received!</h4> </div> <div class="modal-body"> - <span>Please wait while we create your account. This may take up to 5-10 minutes.</span> + <span>Sit tight while we certify your account.</span> <img src="{{ url_for('static', filename='img/loading.gif') }}" width="40px"> </div> </div> -- GitLab From 96aad0c5950ea3ea4c26b7edaf9dc45aa1a2d9b7 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Wed, 13 Apr 2022 15:29:17 -0500 Subject: [PATCH 10/30] added rc_util import --- app/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 7cec40b..9514ef8 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -12,6 +12,10 @@ from flask_bootstrap import Bootstrap import random import os import json +import sys + +sys.path.append(vars.rabbitmq_agents_loc) +import rc_util def create_app(config_name): app = Flask(__name__, static_folder='static') # initialization of the flask app @@ -36,7 +40,7 @@ def create_app(config_name): @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page def index(): - invalid_eppa = ["staff"] + invalid_eppa = ["staff", "affiliate"] if 'uid' not in session: session['uid']=str(uuid.uuid4()) @@ -46,9 +50,8 @@ def create_app(config_name): session['return_url'] = request.args.get('redir', vars.default_referrer) - -# if session['user'].get('eppa') not in invalid_eppa: -# return render_template('errors/blocked.html', title='shibboleth error') + if(any(item in session['user'].get('eppa') for item in invalid_eppa)): + return render_template('errors/shibboleth.html', title='shibboleth error') if rc_util.check_state(session['user'].get('username')) == "blocked": return render_template('errors/blocked.html') -- GitLab From 7ba847f87ab4d69f16794a9e31c0ed90475d9ca3 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Wed, 13 Apr 2022 15:30:55 -0500 Subject: [PATCH 11/30] added shibboleth error page --- app/templates/errors/shibboleth.html | 74 ++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 app/templates/errors/shibboleth.html diff --git a/app/templates/errors/shibboleth.html b/app/templates/errors/shibboleth.html new file mode 100644 index 0000000..df972e1 --- /dev/null +++ b/app/templates/errors/shibboleth.html @@ -0,0 +1,74 @@ +<html class="gr__rc_uab_edu"> +<title>User Blocked </title> +<head> +<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> +<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script> +<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> +<script src="{{ url_for('static', filename='scripts/function.js') }}"></script> + + +<link rel="shortcut icon" type="image/x-icon" href="/public/favicon.ico"> +<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/application.css') }}"> +<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/app2.css') }}"> + +<meta name="viewport" content="width=device-width, initial-scale=1"> +<style> + .navbar-inverse { background-color: rgb(0,99,65); } + button{ margin: 13px; + .important { color: #336699; }} +</style> + +</head> + + +<body data-gr-c-s-loaded="true"> +<header> + <nav class="navbar navbar-inverse navbar-static-top"> + <div class="container-fluid"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> + <a class="navbar-brand" href="/"> UAB Research Computing</a> + </div> + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9"> + <div class="navbar-right"> + <ul class="nav navbar-nav"> + <li> + <a target="_blank" href="https://docs.uabgrid.uab.edu/wiki/Cheaha_GettingStarted"> + <i class="fas fa-info-circle fa-fw"></i> Online Documentation + </a> + </li> + </ul> + </div> + </div> + </div> + </nav> +</header> + +<div class="container content" role="main" style="width: 100%"> + <div class="col-md-2 col-sm-2 my-col"> + <img alt="logo" height="auto" width="80%" src="{{ url_for('static', filename='img/logo_svg.svg') }}"> + <a href="https://tinyurl.com/cheahaAL" target="_blank"></a> + </div> + + <div class="col-md-10 col-sm-10 my-col"> + <div id="form-wrapper"> + <h2> Account SHIB error </h2> + <p style="font-size:110%;"> {{ welcome_msg |safe }}</p> + </div> + </div> +</div> + +<footer> + <div class="container-fluid"> + <div class="row"> + <div class="col-md-6 col-sm-6"> + <a href="https://osc.github.io/Open-OnDemand/"> + <img class="footer-logo" alt="Powered by Open OnDemand" height="40" style="margin-bottom: 20px" src="{{ url_for('static', filename='img/OpenOnDemand_powered_by_RGB-cb3aad5ff5350c7994f250fb334ddcc72e343233ce99eb71fda93beddd76a847.svg') }}"> + </a> + </div> + </div> + </div> +</footer> + +</body> +</html> -- GitLab From 54bf701a6d124d4985c538e6670d87ef8b6b37e0 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Wed, 13 Apr 2022 15:33:28 -0500 Subject: [PATCH 12/30] added invalid eppa values --- app/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index 9514ef8..5eb3328 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -40,7 +40,7 @@ def create_app(config_name): @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page def index(): - invalid_eppa = ["staff", "affiliate"] + invalid_eppa = ["alum", "library-walk-in"] if 'uid' not in session: session['uid']=str(uuid.uuid4()) -- GitLab From fb98ad6256a6e3bb0bd773006f0345466c942716 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Wed, 13 Apr 2022 15:56:05 -0500 Subject: [PATCH 13/30] removed shibboleth condition --- app/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 5eb3328..3c08d4d 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -50,8 +50,8 @@ def create_app(config_name): session['return_url'] = request.args.get('redir', vars.default_referrer) - if(any(item in session['user'].get('eppa') for item in invalid_eppa)): - return render_template('errors/shibboleth.html', title='shibboleth error') +# if(any(item in session['user'].get('eppa') for item in invalid_eppa)): +# return render_template('errors/shibboleth.html', title='shibboleth error') if rc_util.check_state(session['user'].get('username')) == "blocked": return render_template('errors/blocked.html') -- GitLab From 52ef22b03e5985602d70fae53e90957f136b056a Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Thu, 14 Apr 2022 10:08:08 -0500 Subject: [PATCH 14/30] Feat- Parse Shibboleth eduPersonAffiliationValues attribute 1. Set a valid set of eppa values 2. Check if user's attributes match with any of the valid set of eppa values 3. If no match with user's eppa and valid set, redir to shib error page --- app/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 3c08d4d..c54bb01 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -40,7 +40,7 @@ def create_app(config_name): @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page def index(): - invalid_eppa = ["alum", "library-walk-in"] + valid_eppa = ["faculty", "staff", "student", "affliate"] if 'uid' not in session: session['uid']=str(uuid.uuid4()) @@ -50,8 +50,8 @@ def create_app(config_name): session['return_url'] = request.args.get('redir', vars.default_referrer) -# if(any(item in session['user'].get('eppa') for item in invalid_eppa)): -# return render_template('errors/shibboleth.html', title='shibboleth error') + if (not any(item in session['user'].get('eppa') for item in valid_eppa)): + return render_template('errors/shibboleth.html', title='shibboleth error') if rc_util.check_state(session['user'].get('username')) == "blocked": return render_template('errors/blocked.html') @@ -71,7 +71,7 @@ def create_app(config_name): referrer=session['return_url'], cancel_url=vars.default_referrer, welcome_msg=messages.welcome_message, cancel_msg=messages.cancel_message, - error_msg=messages.error_message) + if (not any(item in session['user'].get('eppa') for item in valid_eppa)): error_msg=messages.error_message) @app.route('/blocked_account') -- GitLab From 1a36137277a6edc5d9fc89365a6bd63e8c0c0f0a Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Thu, 14 Apr 2022 10:44:57 -0500 Subject: [PATCH 15/30] code cleanup --- app/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index c54bb01..b043cd8 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -71,8 +71,6 @@ def create_app(config_name): referrer=session['return_url'], cancel_url=vars.default_referrer, welcome_msg=messages.welcome_message, cancel_msg=messages.cancel_message, - if (not any(item in session['user'].get('eppa') for item in valid_eppa)): error_msg=messages.error_message) - @app.route('/blocked_account') def account_block(): -- GitLab From 5943e059bbc48696cb8a59ee73a0c2b516bfeca4 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Thu, 14 Apr 2022 10:45:50 -0500 Subject: [PATCH 16/30] code fix --- app/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/__init__.py b/app/__init__.py index b043cd8..639dc5b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -71,6 +71,7 @@ def create_app(config_name): referrer=session['return_url'], cancel_url=vars.default_referrer, welcome_msg=messages.welcome_message, cancel_msg=messages.cancel_message, + error_msg=messages.error_message) @app.route('/blocked_account') def account_block(): -- GitLab From bee2398567a91c6877fc102f52ae169aefe5b47d Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Fri, 15 Apr 2022 10:08:50 -0500 Subject: [PATCH 17/30] replaced page title --- app/__init__.py | 2 +- app/templates/errors/shibboleth.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 639dc5b..890e8ef 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -51,7 +51,7 @@ def create_app(config_name): session['return_url'] = request.args.get('redir', vars.default_referrer) if (not any(item in session['user'].get('eppa') for item in valid_eppa)): - return render_template('errors/shibboleth.html', title='shibboleth error') + return render_template('errors/shibboleth.html') if rc_util.check_state(session['user'].get('username')) == "blocked": return render_template('errors/blocked.html') diff --git a/app/templates/errors/shibboleth.html b/app/templates/errors/shibboleth.html index df972e1..fffdd9d 100644 --- a/app/templates/errors/shibboleth.html +++ b/app/templates/errors/shibboleth.html @@ -1,5 +1,5 @@ <html class="gr__rc_uab_edu"> -<title>User Blocked </title> +<title>User Shibboleth error </title> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script> -- GitLab From 7df02eea47a7759ddcea0b8143fc13ccab4bed80 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Fri, 15 Apr 2022 10:47:02 -0500 Subject: [PATCH 18/30] removed typo for affiliate --- app/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index 890e8ef..653dddf 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -40,7 +40,7 @@ def create_app(config_name): @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page def index(): - valid_eppa = ["faculty", "staff", "student", "affliate"] + valid_eppa = ["faculty", "staff", "student", "affiliate"] if 'uid' not in session: session['uid']=str(uuid.uuid4()) -- GitLab From cd62860a5d9526d0ca5dd830fe08958ec766afbf Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 18 Apr 2022 14:35:02 -0500 Subject: [PATCH 19/30] Feat certify account 1. Replaced function call rc_util.update_state with rc_util.certify_account 2. Added callback function for certify_account --- tasks.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tasks.py b/tasks.py index 5721e47..2a2c328 100644 --- a/tasks.py +++ b/tasks.py @@ -35,6 +35,25 @@ def gen_f(room): rc_util.rc_rmq.delete_queue() return callback +def certify_gen_f(room): + def callback(channel, method, properties, body): + msg = json.loads(body) + username = msg['username'] + + if msg['success']: + print(f'Account for {username} has been certified.') + send_msg('certified', room) + else: + print(f"There's some issue while certifying account for {username}") + errmsg = msg.get('errmsg', []) + for err in errmsg: + print(err) + socketio.emit('certify error', errmsg, room= room) + + rc_util.rc_rmq.stop_consume() + rc_util.rc_rmq.delete_queue() + return callback + def send_msg(event, room): socketio.emit(event, room=room) @@ -72,7 +91,7 @@ def celery_certify_account(json, session): print("CERTIFY : "+time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue') send_msg('certifying account', room) print(username) - rc_util.update_state(username, 'ok') + rc_util.certify_account(username, queuename, 'ok', 'all') print('sent account info') print('Waiting for certification...') - send_msg('certified', room) + rc_util.consume(queuename, routing_key=f'certified.{queuename}', callback=certify_gen_f(room)) -- GitLab From 908b1c63f2d665454b8b66f970b83ddfe1d49c02 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 18 Apr 2022 15:38:24 -0500 Subject: [PATCH 20/30] fixed typos --- app/templates/errors/certify.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/errors/certify.html b/app/templates/errors/certify.html index 231acb2..abb4a46 100644 --- a/app/templates/errors/certify.html +++ b/app/templates/errors/certify.html @@ -25,10 +25,10 @@ window.location.replace('{{ referrer }}'); }); - socket.on( 'account error', function( msg ) { + socket.on( 'certify error', function( msg ) { console.log(msg); $('#myModal2').modal('hide'); - renderDom("Account Create Error", "{{ error_msg }}", msg); + renderDom("Account Certification Error", "{{ error_msg }}", msg); }); }); -- GitLab From 3555370c5a052eff8b171997ed53a68200bea19d Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 18 Apr 2022 22:19:59 -0500 Subject: [PATCH 21/30] added queuename to callback function for delete_queue --- tasks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index 2a2c328..4dd5608 100644 --- a/tasks.py +++ b/tasks.py @@ -39,6 +39,7 @@ def certify_gen_f(room): def callback(channel, method, properties, body): msg = json.loads(body) username = msg['username'] + queuename = msg['username'] if msg['success']: print(f'Account for {username} has been certified.') @@ -51,7 +52,7 @@ def certify_gen_f(room): socketio.emit('certify error', errmsg, room= room) rc_util.rc_rmq.stop_consume() - rc_util.rc_rmq.delete_queue() + rc_util.rc_rmq.delete_queue(queuename) return callback def send_msg(event, room): -- GitLab From b6128e13edbaaf2f18672cbd218f4efeb5c20d19 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 18 Apr 2022 22:24:55 -0500 Subject: [PATCH 22/30] removed shibboleth eppa parameter --- app/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 3c08d4d..f1736fb 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -40,8 +40,6 @@ def create_app(config_name): @app.route('/', methods=['GET', 'POST']) # initial route to display the reg page def index(): - invalid_eppa = ["alum", "library-walk-in"] - if 'uid' not in session: session['uid']=str(uuid.uuid4()) -- GitLab From 371326c66ca75fef55a7124947b62ed171cb3ab4 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 18 Apr 2022 22:29:25 -0500 Subject: [PATCH 23/30] removed shibboleth html code --- app/templates/errors/shibboleth.html | 74 ---------------------------- 1 file changed, 74 deletions(-) delete mode 100644 app/templates/errors/shibboleth.html diff --git a/app/templates/errors/shibboleth.html b/app/templates/errors/shibboleth.html deleted file mode 100644 index df972e1..0000000 --- a/app/templates/errors/shibboleth.html +++ /dev/null @@ -1,74 +0,0 @@ -<html class="gr__rc_uab_edu"> -<title>User Blocked </title> -<head> -<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> -<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script> -<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> -<script src="{{ url_for('static', filename='scripts/function.js') }}"></script> - - -<link rel="shortcut icon" type="image/x-icon" href="/public/favicon.ico"> -<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/application.css') }}"> -<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/app2.css') }}"> - -<meta name="viewport" content="width=device-width, initial-scale=1"> -<style> - .navbar-inverse { background-color: rgb(0,99,65); } - button{ margin: 13px; - .important { color: #336699; }} -</style> - -</head> - - -<body data-gr-c-s-loaded="true"> -<header> - <nav class="navbar navbar-inverse navbar-static-top"> - <div class="container-fluid"> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> - <a class="navbar-brand" href="/"> UAB Research Computing</a> - </div> - <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9"> - <div class="navbar-right"> - <ul class="nav navbar-nav"> - <li> - <a target="_blank" href="https://docs.uabgrid.uab.edu/wiki/Cheaha_GettingStarted"> - <i class="fas fa-info-circle fa-fw"></i> Online Documentation - </a> - </li> - </ul> - </div> - </div> - </div> - </nav> -</header> - -<div class="container content" role="main" style="width: 100%"> - <div class="col-md-2 col-sm-2 my-col"> - <img alt="logo" height="auto" width="80%" src="{{ url_for('static', filename='img/logo_svg.svg') }}"> - <a href="https://tinyurl.com/cheahaAL" target="_blank"></a> - </div> - - <div class="col-md-10 col-sm-10 my-col"> - <div id="form-wrapper"> - <h2> Account SHIB error </h2> - <p style="font-size:110%;"> {{ welcome_msg |safe }}</p> - </div> - </div> -</div> - -<footer> - <div class="container-fluid"> - <div class="row"> - <div class="col-md-6 col-sm-6"> - <a href="https://osc.github.io/Open-OnDemand/"> - <img class="footer-logo" alt="Powered by Open OnDemand" height="40" style="margin-bottom: 20px" src="{{ url_for('static', filename='img/OpenOnDemand_powered_by_RGB-cb3aad5ff5350c7994f250fb334ddcc72e343233ce99eb71fda93beddd76a847.svg') }}"> - </a> - </div> - </div> - </div> -</footer> - -</body> -</html> -- GitLab From 38dc5060f6c2d91087023ea749d87d12c9e769f8 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 18 Apr 2022 22:34:36 -0500 Subject: [PATCH 24/30] fixed page title --- app/templates/errors/shibboleth.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/errors/shibboleth.html b/app/templates/errors/shibboleth.html index fffdd9d..f4a5cf5 100644 --- a/app/templates/errors/shibboleth.html +++ b/app/templates/errors/shibboleth.html @@ -1,5 +1,5 @@ <html class="gr__rc_uab_edu"> -<title>User Shibboleth error </title> +<title>User Authorization error </title> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script> @@ -52,7 +52,7 @@ <div class="col-md-10 col-sm-10 my-col"> <div id="form-wrapper"> - <h2> Account SHIB error </h2> + <h2> Account Authorization error </h2> <p style="font-size:110%;"> {{ welcome_msg |safe }}</p> </div> </div> -- GitLab From 1299751632a29c363f77c04dbcec72879374aff6 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 18 Apr 2022 14:35:02 -0500 Subject: [PATCH 25/30] Feat certify account 1. Replaced function call rc_util.update_state with rc_util.certify_account 2. Added callback function for certify_account --- tasks.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tasks.py b/tasks.py index 5721e47..2a2c328 100644 --- a/tasks.py +++ b/tasks.py @@ -35,6 +35,25 @@ def gen_f(room): rc_util.rc_rmq.delete_queue() return callback +def certify_gen_f(room): + def callback(channel, method, properties, body): + msg = json.loads(body) + username = msg['username'] + + if msg['success']: + print(f'Account for {username} has been certified.') + send_msg('certified', room) + else: + print(f"There's some issue while certifying account for {username}") + errmsg = msg.get('errmsg', []) + for err in errmsg: + print(err) + socketio.emit('certify error', errmsg, room= room) + + rc_util.rc_rmq.stop_consume() + rc_util.rc_rmq.delete_queue() + return callback + def send_msg(event, room): socketio.emit(event, room=room) @@ -72,7 +91,7 @@ def celery_certify_account(json, session): print("CERTIFY : "+time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue') send_msg('certifying account', room) print(username) - rc_util.update_state(username, 'ok') + rc_util.certify_account(username, queuename, 'ok', 'all') print('sent account info') print('Waiting for certification...') - send_msg('certified', room) + rc_util.consume(queuename, routing_key=f'certified.{queuename}', callback=certify_gen_f(room)) -- GitLab From 5a73c133a958b27288e2be3241eafb4e8ddb74ac Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 18 Apr 2022 15:38:24 -0500 Subject: [PATCH 26/30] fixed typos --- app/templates/errors/certify.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/errors/certify.html b/app/templates/errors/certify.html index 231acb2..abb4a46 100644 --- a/app/templates/errors/certify.html +++ b/app/templates/errors/certify.html @@ -25,10 +25,10 @@ window.location.replace('{{ referrer }}'); }); - socket.on( 'account error', function( msg ) { + socket.on( 'certify error', function( msg ) { console.log(msg); $('#myModal2').modal('hide'); - renderDom("Account Create Error", "{{ error_msg }}", msg); + renderDom("Account Certification Error", "{{ error_msg }}", msg); }); }); -- GitLab From 155e8c4697bfa8ca11aac07af4dcb3cb09f42d28 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Mon, 18 Apr 2022 22:19:59 -0500 Subject: [PATCH 27/30] added queuename to callback function for delete_queue --- tasks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index 2a2c328..4dd5608 100644 --- a/tasks.py +++ b/tasks.py @@ -39,6 +39,7 @@ def certify_gen_f(room): def callback(channel, method, properties, body): msg = json.loads(body) username = msg['username'] + queuename = msg['username'] if msg['success']: print(f'Account for {username} has been certified.') @@ -51,7 +52,7 @@ def certify_gen_f(room): socketio.emit('certify error', errmsg, room= room) rc_util.rc_rmq.stop_consume() - rc_util.rc_rmq.delete_queue() + rc_util.rc_rmq.delete_queue(queuename) return callback def send_msg(event, room): -- GitLab From b4097f606f6099ca01bdafaedcfded2a1aa4f3ae Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Tue, 19 Apr 2022 01:15:28 -0500 Subject: [PATCH 28/30] removed user_authorization shibboleth if condition --- app/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 843e07c..8f9352e 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -48,8 +48,8 @@ def create_app(config_name): session['return_url'] = request.args.get('redir', vars.default_referrer) - if (not any(item in session['user'].get('eppa') for item in valid_eppa)): - return render_template('errors/shibboleth.html') +# if (not any(item in session['user'].get('eppa') for item in valid_eppa)): +# return render_template('errors/shibboleth.html') if rc_util.check_state(session['user'].get('username')) == "blocked": return render_template('errors/blocked.html') -- GitLab From 0d5e4aaf05e489939256ab14dcb8137552575de9 Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Tue, 19 Apr 2022 01:18:10 -0500 Subject: [PATCH 29/30] removed unused certification page --- app/templates/errors/certification.html | 75 ------------------------- 1 file changed, 75 deletions(-) delete mode 100644 app/templates/errors/certification.html diff --git a/app/templates/errors/certification.html b/app/templates/errors/certification.html deleted file mode 100644 index 529b7c7..0000000 --- a/app/templates/errors/certification.html +++ /dev/null @@ -1,75 +0,0 @@ -<html class="gr__rc_uab_edu"> -<title>User Certification Needed </title> -<head> -<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> -<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.min.js"></script> -<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> -<script src="{{ url_for('static', filename='scripts/function.js') }}"></script> - - -<link rel="shortcut icon" type="image/x-icon" href="/public/favicon.ico"> -<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/application.css') }}"> -<link rel="stylesheet" media="all" href="{{ url_for('static', filename='style/app2.css') }}"> - -<meta name="viewport" content="width=device-width, initial-scale=1"> -<style> - .navbar-inverse { background-color: rgb(0,99,65); } - button{ margin: 13px; - .important { color: #336699; }} -</style> - -</head> - - -<body data-gr-c-s-loaded="true"> -<header> - <nav class="navbar navbar-inverse navbar-static-top"> - <div class="container-fluid"> - <div class="navbar-header"> - <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> - <a class="navbar-brand" href="/"> UAB Research Computing</a> - </div> - <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-9"> - <div class="navbar-right"> - <ul class="nav navbar-nav"> - <li> - <a target="_blank" href="https://docs.uabgrid.uab.edu/wiki/Cheaha_GettingStarted"> - <i class="fas fa-info-circle fa-fw"></i> Online Documentation - </a> - </li> - </ul> - </div> - </div> - </div> - </nav> -</header> - -<div class="container content" role="main" style="width: 100%"> - <div class="col-md-2 col-sm-2 my-col"> - <img alt="logo" height="auto" width="80%" src="{{ url_for('static', filename='img/logo_svg.svg') }}"> - <a href="https://tinyurl.com/cheahaAL" target="_blank"></a> - </div> - - <div class="col-md-10 col-sm-10 my-col"> - <div id="form-wrapper"> - <h2> Account/User Certification Needed </h2> - <p style="font-size:110%;"> {{ welcome_msg |safe }}</p> - <button class="btn btn-primary btn-md" id="submit" name="submit" type="button" value="Submit" onclick="accountCertification()"> Certify Account</button> - </div> - </div> -</div> - -<footer> - <div class="container-fluid"> - <div class="row"> - <div class="col-md-6 col-sm-6"> - <a href="https://osc.github.io/Open-OnDemand/"> - <img class="footer-logo" alt="Powered by Open OnDemand" height="40" style="margin-bottom: 20px" src="{{ url_for('static', filename='img/OpenOnDemand_powered_by_RGB-cb3aad5ff5350c7994f250fb334ddcc72e343233ce99eb71fda93beddd76a847.svg') }}"> - </a> - </div> - </div> - </div> -</footer> - -</body> -</html> -- GitLab From f544d8b14fa212b99b6417322b5f97ae98836edb Mon Sep 17 00:00:00 2001 From: Krish M <krish94@uab.edu> Date: Tue, 19 Apr 2022 01:22:29 -0500 Subject: [PATCH 30/30] renamed route certify_account --- app/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index 8f9352e..6880ec6 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -77,7 +77,7 @@ def create_app(config_name): @app.route('/certify_account') def error_certify(): - return render_template('errors/certification.html') + return render_template('errors/certify.html') # misc page error catching @app.errorhandler(403) -- GitLab