【问题标题】:Spring Security : Call from external website unable to redirect to our applicationSpring Security:来自外部网站的调用无法重定向到我们的应用程序
【发布时间】:2015-05-30 01:39:21
【问题描述】:

我们正在开发一个基于 Spring 的 Web 应用程序,它使用 Spring Security 3.2.3。我们正在与外部支付网关 (Paytm) 集成以接受用户的付款。以下是我们面临问题的场景:

  1. 用户登录到应用程序(这是一个HTTP 非 S 应用程序)并单击一个按钮 将他重定向到支付网关(Paytm支付网关 - 它是HTTPS url)。
  2. 对于Paytm 集成,我们配置了一个回调URL,即我们应用程序的索引页面(例如http://server:port/app/index.jsp)。用户完成支付,Paytm 将控件重定向回我们的 Spring 应用程序。
  3. Paytm 尝试调用我们应用的索引页面(例如http://server:port/app/index.jsp)时,它失败了,在Chrome 调试器中,我们可以看到403 Forbidden 响应。
  4. 但是,此方案在 Mozilla FirexfoxIE 11 中运行良好。该问题仅在 Google ChromeOperabrowsers 中出现。
  5. 我们尝试在回调 URL 中提供一些其他网站(如 https://google.com),重定向成功。

我们怀疑它可能是 Spring Security 中的一些配置问题或缺少设置,但我们不确定。

这是我们的 Spring Security 配置:

<http auto-config="true" use-expressions="true">
        <!-- Un-comment when authorization is implemented -->
        <intercept-url pattern="/**" access="isAuthenticated()"/>
        <form-login authentication-failure-handler-ref="failureHandler"
            authentication-success-handler-ref="successHandler" />
        <intercept-url pattern="/**" />
        <logout logout-success-url="${login.page.url}" />
    </http>

    <authentication-manager alias="authenticationManager">
        <authentication-provider>
            <password-encoder ref="encoder" />
            <jdbc-user-service data-source-ref="dataSource"
                users-by-username-query="select gu.email, gu.password, gu.enabled from global_user gu,global_organization_user gou, global_organization go where email=? and gu.enabled=1 and gu.is_deleted=0 and gou.user_id = gu.id and gou.organization_id=go.id and go.current_stage='ACTIVE' and go.is_deleted=0"
                authorities-by-username-query="select u.email, r.role_id from global_user u, security_user_role r
                where u.id = r.user_id and u.email=?" />
        </authentication-provider>
    </authentication-manager>

    <beans:bean id="encoder"
        class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" />
    <beans:bean id="successHandler"
        class="app.server.security.authentication.AuthenticationSuccessHandler" />
    <beans:bean id="failureHandler"
        class="app.server.security.authentication.AuthenticationFailureHandler" />

    <beans:bean id="expressionHandler"
        class="app.server.security.authorization.CustomMethodSecurityExpressionHandler">
        <beans:property name="permissionEvaluator" ref="authorizationEvaluator">
        </beans:property>
    </beans:bean>

    <beans:bean id="authorizationEvaluator"
        class="app.server.security.authorization.AuthorizationEvaluator" />


    <global-method-security pre-post-annotations="enabled">
        <expression-handler ref="expressionHandler" />
    </global-method-security>

    <http pattern="/rest/app/someurl**" security="none"/>
    // other URLs which are escaped from spring security

感谢任何建议和指点。

【问题讨论】:

    标签: java spring jsp spring-security payment-gateway


    【解决方案1】:

    通过将支付网关响应重定向到一个中间 URL(我们创建了一个单独的 Web 项目并提供了它的链接)暂时解决了这个问题。这个中间 URL 然后将控件重定向到我们的 Spring 应用程序。

    【讨论】:

      【解决方案2】:

      这个问题也在我的本地主机站点上使用 https 解决了。 添加 SSL 证书并尝试一下。

      【讨论】:

        【解决方案3】:

        面临与 op 类似的问题,但我们设法通过将回调 URL 配置为使用 https 而不是 http 来解决此问题。但是,这可能不适用于每个人,因为每个支付网关都有不同的安全控制。希望这会有所帮助!

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-05-27
          • 2016-05-16
          • 2015-12-13
          • 2018-03-04
          • 2014-01-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多