Fix linter errors

This commit is contained in:
Seamus Johnston 2022-09-22 15:57:40 -05:00
parent 00f87168e5
commit f16d657c6a
No known key found for this signature in database
GPG key ID: 2F21225985069105
5 changed files with 101 additions and 97 deletions

View file

@ -2,18 +2,13 @@
import logging
try:
from urllib.parse import parse_qs, urlencode
except ImportError:
from urllib import urlencode
from urlparse import parse_qs
from django.conf import settings
from django.contrib.auth import logout as auth_logout
from django.contrib.auth import authenticate, login
from django.http import HttpResponseRedirect
from django.shortcuts import redirect, render
from urllib.parse import parse_qs, urlencode
from djangooidc.oidc import Client
from djangooidc import exceptions as o_e
@ -35,9 +30,9 @@ def error_page(request, error):
"401.html",
context={
"friendly_message": error.friendly_message,
"log_identifier": error.locator
"log_identifier": error.locator,
},
status=401
status=401,
)
if isinstance(error, o_e.InternalError):
return render(
@ -45,13 +40,14 @@ def error_page(request, error):
"500.html",
context={
"friendly_message": error.friendly_message,
"log_identifier": error.locator
"log_identifier": error.locator,
},
status=500
status=500,
)
if isinstance(error, Exception):
return render(request, "500.html", status=500)
def openid(request):
"""Redirect the user to an authentication provider (OP)."""
request.session["next"] = request.GET.get("next", "/")
@ -61,6 +57,7 @@ def openid(request):
except Exception as err:
return error_page(request, err)
def login_callback(request):
"""Analyze the token returned by the authentication provider (OP)."""
try:
@ -90,11 +87,13 @@ def logout(request, next_page=None):
"post_logout_redirect_uris" in CLIENT.registration_response.keys()
and len(CLIENT.registration_response["post_logout_redirect_uris"]) > 0
):
request_args.update({
"post_logout_redirect_uri":
CLIENT.registration_response["post_logout_redirect_uris"][0]
})
request_args.update(
{
"post_logout_redirect_uri": CLIENT.registration_response[
"post_logout_redirect_uris"
][0]
}
)
url = CLIENT.provider_info["end_session_endpoint"]
url += "?" + urlencode(request_args)
@ -110,6 +109,7 @@ def logout(request, next_page=None):
if next_page:
request.session["next"] = next_page
def logout_callback(request):
"""Simple redirection view: after logout, redirect to `next`."""
next = request.session["next"] if "next" in request.session.keys() else "/"