providers/oauth2: fix error when redirecting from an authorization error

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-03-20 22:06:45 +01:00
parent 3eacd8b754
commit 43f19f78bb

View file

@ -6,7 +6,7 @@ from urllib.parse import parse_qs, urlencode, urlsplit, urlunsplit
from uuid import uuid4
from django.http import HttpRequest, HttpResponse
from django.http.response import Http404
from django.http.response import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect
from django.utils import timezone
from django.utils.translation import gettext as _
@ -384,7 +384,7 @@ class AuthorizationFlowInitView(PolicyAccessView):
self.params = OAuthAuthorizationParams.from_request(self.request)
except AuthorizeError as error:
error.to_event(redirect_uri=error.redirect_uri).from_http(self.request)
raise RequestValidationError(redirect(error.create_uri()))
raise RequestValidationError(HttpResponseRedirect(error.create_uri()))
except OAuth2Error as error:
error.to_event().from_http(self.request)
raise RequestValidationError(
@ -401,7 +401,7 @@ class AuthorizationFlowInitView(PolicyAccessView):
self.params.state,
)
error.to_event(redirect_uri=error.redirect_uri).from_http(self.request)
raise RequestValidationError(redirect(error.create_uri()))
raise RequestValidationError(HttpResponseRedirect(error.create_uri()))
def resolve_provider_application(self):
client_id = self.request.GET.get("client_id")