0

我的目标是在页面上有一个链接,将用户返回到原始站点。我从 spring saml 示例http://projects.spring.io/spring-security-saml/开始,并正在添加一个新功能索引页。

我的 saml-servlet.xml 和 securityContext.xml 都有

<context:component-scan base-package="com.home.saml.sp"/>

我在 com.home.saml.sp 包中的 returnController.java

@Controller
public class ReturnController {

    @RequestMapping(value = "/redirect", method = RequestMethod.POST)
    public String redirect() {
        String redirectUrl = "http://www.home.com";
        return "redirect:"+ redirectUrl; 
    }
}

我的 index.jsp 添加

<form method="POST" action="/redirect">
    <table>
        <tr>
            <td><input type="submit" value="Redirect * Page" /></td>
        </tr>
    </table>
</form>
4

1 回答 1

0

saml servlet 处理 URL /saml/web/*,因此会跳过您的/redirect控制器。您需要将 saml servlet 映射更改web.xml为:

<servlet-mapping>
    <servlet-name>saml</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

请注意,这将破坏示例应用程序中的元数据管理 UI。您需要将管理 UI 的当前安全性替换为:

<!-- Security for the administration UI -->
<security:http pattern="/metadata/**" access-denied-page="/metadata/login">
    <security:form-login login-processing-url="/metadata/login_check" login-page="/metadata/login" default-target-url="/metadata"/>
    <security:intercept-url pattern="/metadata/login" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
    <security:intercept-url pattern="/metadata/**" access="ROLE_ADMIN"/>
    <security:custom-filter before="FIRST" ref="metadataGeneratorFilter"/>
</security:http>

然后删除/saml/webJSP 中的所有前缀并更改adminLogin.jsp/metadata/login_checkloginForm.

于 2014-08-21T06:49:56.733 回答