Yan*_*lem 5 java spring spring-security spring-security-oauth2
是否可以为Spring Oauth2 Sso服务设置默认登录成功?
继szenario之后
index.htmlindex.htmlmanifest属性==>浏览器请求清单${sso.host}/login${sso.host}/login查询字符串中的代码有没有办法不重定向到受保护的上次请求的资源,但默认情况下重定向到'index.html'?
即使没有办法实现这一点,请告诉我
Pat*_*era 11
我(我认为)有类似的问题:在我的情况下,一旦SSO请求成功,用户就被重定向到/,这不是我想要的.
有一个内置的解决方案需要一些挖掘才能找到.
该AbstractAuthenticationProcessingFilter有一个方法setAuthenticationSuccessHandler,可以让你控制这一点,所以如果你有访问OAuth2ClientAuthenticationProcessingFilter,你可以将其设置为你想要的.
如果您有类似于教程的设置:https://spring.io/guides/tutorials/spring-boot-oauth2/#_social_login_manual,那么您只需将以下内容添加到OAuth2ClientAuthenticationProcessingFilter教程中创建的内容中:
OAuth2ClientAuthenticationProcessingFilter oauth2Filter = new OAuth2ClientAuthenticationProcessingFilter("/XXXProvider/login");
oauth2Filter.setAuthenticationSuccessHandler(new SimpleUrlAuthenticationSuccessHandler() {
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
this.setDefaultTargetUrl("/my_preferred_location");
super.onAuthenticationSuccess(request, response, authentication);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5653 次 |
| 最近记录: |