我想用lang来标记languages.In认证的过程,这个参数丢失了
I want to used lang to mark languages.In the process of authentication,This parameter is lost
http://localhost:8080/auth/login?lang=en
我想用lang
来标记languages.In认证的过程,这个参数丢失了。
我阅读了源代码。
LoginUrlAuthenticationEntryPoint.commence
```java
public 无效开始(HttpServletRequest 请求,HttpServletResponse 响应,
AuthenticationException authException) 抛出 IOException, ServletException {
String redirectUrl = null;
if (useForward) {
if (forceHttps && "http".equals(request.getScheme())) {
// First redirect the current request to HTTPS.
// When that request is received, the forward to the login page will be
// used.
redirectUrl = buildHttpsRedirectUrlForRequest(request);
}
if (redirectUrl == null) {
String loginForm = determineUrlToUseForThisRequest(request, response,
authException);
if (logger.isDebugEnabled()) {
logger.debug("Server side forward to: " + loginForm);
}
RequestDispatcher dispatcher = request.getRequestDispatcher(loginForm);
dispatcher.forward(request, response);
return;
}
}
else {
// redirect to login page. Use https if forceHttps true
redirectUrl = buildRedirectUrlToLoginPage(request, response, authException);
}
redirectStrategy.sendRedirect(request, response, redirectUrl);
}
```
重写redirectUrl
AbstractAuthenticationFilterConfigurer
java
private void addAuthenticationEntryPoint(HttpSecurity http, OAuth2SsoProperties sso)
throws Exception {
...
exceptions.defaultAuthenticationEntryPointFor(
new LoginUrlAuthenticationEntryPoint(sso.getLoginPath()),
preferredMatcher);
...
}
需要覆盖太多代码。
不知是不是我没有找到合适的现有配置来解决这个问题
已通过过滤器解决
在会话中保存消息
http://localhost:8080/auth/login?lang=en
我想用lang
来标记languages.In认证的过程,这个参数丢失了。
我阅读了源代码。
LoginUrlAuthenticationEntryPoint.commence
```java
public 无效开始(HttpServletRequest 请求,HttpServletResponse 响应,
AuthenticationException authException) 抛出 IOException, ServletException {
String redirectUrl = null;
if (useForward) {
if (forceHttps && "http".equals(request.getScheme())) {
// First redirect the current request to HTTPS.
// When that request is received, the forward to the login page will be
// used.
redirectUrl = buildHttpsRedirectUrlForRequest(request);
}
if (redirectUrl == null) {
String loginForm = determineUrlToUseForThisRequest(request, response,
authException);
if (logger.isDebugEnabled()) {
logger.debug("Server side forward to: " + loginForm);
}
RequestDispatcher dispatcher = request.getRequestDispatcher(loginForm);
dispatcher.forward(request, response);
return;
}
}
else {
// redirect to login page. Use https if forceHttps true
redirectUrl = buildRedirectUrlToLoginPage(request, response, authException);
}
redirectStrategy.sendRedirect(request, response, redirectUrl);
}
```
重写redirectUrl
AbstractAuthenticationFilterConfigurer
java
private void addAuthenticationEntryPoint(HttpSecurity http, OAuth2SsoProperties sso)
throws Exception {
...
exceptions.defaultAuthenticationEntryPointFor(
new LoginUrlAuthenticationEntryPoint(sso.getLoginPath()),
preferredMatcher);
...
}
需要覆盖太多代码。 不知是不是我没有找到合适的现有配置来解决这个问题
已通过过滤器解决 在会话中保存消息