openid tests

This commit is contained in:
David Kennedy 2024-02-09 14:25:11 -05:00
parent 1df7dc48df
commit 6820456286
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
2 changed files with 140 additions and 39 deletions

View file

@ -27,6 +27,10 @@ def _initialize_client():
CLIENT = Client(OP)
logger.debug("Client initialized: %s" % CLIENT)
def _client_is_none():
""" Return if the CLIENT is currently None."""
global CLIENT
return CLIENT is None
# Initialize CLIENT
try:
@ -71,7 +75,7 @@ def openid(request):
global CLIENT
try:
# If the CLIENT is none, attempt to reinitialize before handling the request
if CLIENT is None:
if _client_is_none():
_initialize_client()
request.session["acr_value"] = CLIENT.get_default_acr_value()
request.session["next"] = request.GET.get("next", "/")
@ -86,7 +90,7 @@ def login_callback(request):
global CLIENT
try:
# If the CLIENT is none, attempt to reinitialize before handling the request
if CLIENT is None:
if _client_is_none():
_initialize_client()
query = parse_qs(request.GET.urlencode())
userinfo = CLIENT.callback(query, request.session)