【问题标题】:Authentication integration issue between wicket-auth-roles and spring-security-cas-clientwicket-auth-roles 和 spring-security-cas-client 之间的身份验证集成问题
【发布时间】:2013-01-31 03:41:54
【问题描述】:

我的一个 Wicket 项目有问题。 我使用的 wicket 版本是 1.5.7 版本,带有 wicket-auth-roles(相同版本)。

我正在尝试获取 CAS 服务器集成;为此,我正在尝试使用 spring-security-cas-client (3.0.7.RELEASE),但 CAS 身份验证根本不起作用。在这个项目中,我已经在使用 spring-security-core (3.1.0.RELEASE)、spring-security-config 和 spring-security-ldap 并且效果很好。

我遇到的问题是我第一次访问 Wicket 页面时。通常我必须接受 CAS 审讯;但尽管如此,我的自定义authenticatedWebApplication 的方法“getSignInPageClass”(wicket-auth-roles)被调用,我被自动转发到我的登录页面(我根本没有收到任何 CAS 调用)。

有人遇到过这类问题吗?

【问题讨论】:

    标签: java spring-security wicket-1.5


    【解决方案1】:

    我刚刚遇到了同样的问题。为了让它工作,我让 Wicket 重定向到 CAS,然后 CasAuthenticationFilter 验证令牌并处理身份验证。我不知道这是否是最好的解决方案,但我使用了 RequestMapper 来处理 AuthenticatedWebSession 登录。

    Spring 安全配置

    <!-- https://cwiki.apache.org/WICKET/spring-security-and-wicket-auth-roles.html -->
    <http use-expressions="true" auto-config="true" entry-point-ref="casEntryPoint">
        <intercept-url pattern="/**" />
    
        <custom-filter ref="casFilter" position="CAS_FILTER"/>
    </http>
    

    在 AuthenticatedApplication 中覆盖 restartResponseAtSignInPage

    /**
     * Stores original Url and redirects to CAS login for authentication. CAS will redirect back to this
     * service using the service parameter. 
     */
    @Override
    public void restartResponseAtSignInPage() {
        Session.get().setAttribute("originalUrl", RequestCycle.get().getRequest().getOriginalUrl());
        // This will be the URL back to the Spring CAS filter
        String service = "service=https%3A%2F%2F" + casServiceHost + "%2Fapp%2Flogin";
        throw new RedirectToUrlException("https://" + casServerHost + "/cas/login?" + service);
    }
    

    制作一个 IRequestMapper 来处理 AuthenticatedWebSession 登录和重定向。

    @Override
    public IRequestHandler mapRequest(Request request) {
        logger.info("CasAuthMapper mapping {}", request.getUrl());
        // The authentication will have been handled by Spring's CasAuthenticationFilter
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        // ... Do whatever you need to do here. I added a simple method to my web session to delegate to signIn(boolean).
    

    【讨论】:

      猜你喜欢
      • 2012-04-06
      • 1970-01-01
      • 2019-04-08
      • 1970-01-01
      • 1970-01-01
      • 2016-05-29
      • 2012-04-07
      • 1970-01-01
      • 2012-10-25
      相关资源
      最近更新 更多