OAuth2ClientContextFilter会抛出异常,然后在catch里进行重定向
try {
chain.doFilter(servletRequest, servletResponse);
} catch (IOException ex) {
throw ex;
} catch (Exception ex) {
// Try to extract a SpringSecurityException from the stacktrace
Throwable[] causeChain = throwableAnalyzer.determineCauseChain(ex);
UserRedirectRequiredException redirect = (UserRedirectRequiredException) throwableAnalyzer
.getFirstThrowableOfType(
UserRedirectRequiredException.class, causeChain);
if (redirect != null) {
redirectUser(redirect, request, response);
} else {
throw new NestedServletException("Unhandled exception", ex);
}
}
UserRedirectRequiredException 包含了需要重定向的所有信息:
核心的就是redirect url

网友评论