【问题标题】:Spring saml successRedirectHandlerSpring saml successRedirectHandler
【发布时间】:2018-08-25 09:05:57
【问题描述】:

我正在尝试根据他的角色将已经通过 saml 身份验证的用户重定向到特定的默认页面。

例如:

         if user has role A redirect to https://localhost:8443/myApp/A_default_page

         if user has role B redirect to https://localhost:8443/myApp/B_default_page

saml 中的问题,我们只能确定一个:

<bean id="successRedirectHandler"  class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
    <!-- <property name="useReferer" value="true"/> -->
    <property name="defaultTargetUrl" value="here default url "/>

任何帮助。

【问题讨论】:

    标签: redirect single-sign-on spring-saml


    【解决方案1】:

    您可以扩展 SavedRequestAwareAuthenticationSuccessHandler 并覆盖方法

    public void onAuthenticationSuccess(HttpServletRequest request,
                HttpServletResponse response, Authentication authentication)
    

    然后您可以使用身份验证对象来读取角色并选择重定向 url。

    如果你想要这个自定义逻辑,你也可以考虑使用 SimpleUrlAuthenticationSuccessHandler 而不是 SavedRequestAwareAuthenticationSuccessHandler。

    【讨论】:

      猜你喜欢
      • 2013-09-24
      • 2017-11-17
      • 2014-11-05
      • 2017-03-08
      • 2014-09-20
      • 1970-01-01
      • 2016-11-06
      • 2017-03-29
      • 2017-02-15
      相关资源
      最近更新 更多