raise exceptions, map to http error codes
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
from flask import Blueprint, abort, render_template, g, redirect, session, url_for, request
|
||||
from flask import Blueprint, render_template, g, redirect, session, url_for, request
|
||||
from flask import current_app as app
|
||||
import pendulum
|
||||
|
||||
from atst.domain.requests import Requests
|
||||
from atst.domain.users import Users
|
||||
from atst.domain.authnid.utils import parse_sdn
|
||||
from atst.domain.exceptions import UnauthenticatedError
|
||||
|
||||
bp = Blueprint("atst", __name__)
|
||||
|
||||
@@ -29,6 +30,9 @@ def catch_all(path):
|
||||
return render_template("{}.html".format(path))
|
||||
|
||||
|
||||
# TODO: this should be partly consolidated into a domain function that takes
|
||||
# all the necessary UWSGI environment values as args and either returns a user
|
||||
# or raises the UnauthenticatedError
|
||||
@bp.route('/login-redirect')
|
||||
def login_redirect():
|
||||
if request.environ.get('HTTP_X_SSL_CLIENT_VERIFY') == 'SUCCESS' and _is_valid_certificate(request):
|
||||
@@ -39,7 +43,7 @@ def login_redirect():
|
||||
|
||||
return redirect(url_for("atst.home"))
|
||||
else:
|
||||
return abort(401)
|
||||
raise UnauthenticatedError()
|
||||
|
||||
|
||||
def _is_valid_certificate(request):
|
||||
|
Reference in New Issue
Block a user