Merge "Propagate redirect exceptions to the client"

This commit is contained in:
Zuul 2024-01-26 17:37:22 +00:00 committed by Gerrit Code Review
commit 2d48ff27bb
2 changed files with 20 additions and 0 deletions

View File

@ -755,3 +755,20 @@ class OAuth2OtherError(OAuth2Error):
def __init__(self, code, title, message):
error_title = 'other_error'
super().__init__(code, title, error_title, message)
class RedirectRequired(Exception):
"""Error class for redirection.
Child classes should define an HTTP redirect url
message_format.
"""
redirect_url = None
code = http.client.FOUND
def __init__(self, redirect_url, **kwargs):
self.redirect_url = redirect_url
super(RedirectRequired, self).__init__(**kwargs)

View File

@ -78,6 +78,9 @@ def _handle_keystone_exception(error):
elif isinstance(error, exception.OAuth2Error):
return oauth2_handlers.build_response(error)
if isinstance(error, exception.RedirectRequired):
return flask.redirect(error.redirect_url)
# Handle logging
if isinstance(error, exception.Unauthorized):
LOG.warning(