我们正在开发一个基于Spring的Web应用程序,它正在使用Spring Security 3.2.3。我们正在与外部支付网关(Paytm
)集成,以接受用户的付款。以下是我们面临的问题:
HTTP
非S应用程序)并单击一个按钮,将他重定向到支付网关(Paytm
支付网关 - 它是HTTPS
网址)。Paytm
集成,我们已经配置了一个回调URL,即我们的应用程序的索引页面(例如,http://server:port/app/index.jsp
)。用户完成付款,Paytm
将控件重定向回Spring应用程序。Paytm
试图调用我们的应用程序的索引页面(例如http://server:port/app/index.jsp
)时,它失败了,在Chrome调试器中,我们可以看到403 Forbidden
响应。Mozilla Firexfox
和IE 11
中效果很好。这个问题只出现在Google Chrome
和Opera
browsers中。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
任何建议和指示表示赞赏。
通过将支付网关响应重定向到中间URL(我们创建了一个单独的Web项目并提供其链接),可以暂时解决此问题。然后,此中间URL将控件重定向到我们的Spring应用程序。
面临与op相似的问题,但我们设法通过将回调URL配置为使用https而不是http来解决此问题。但是,这可能对每个人都不起作用,因为每个支付网关都有不同的安全控制。希望这有帮助!
我的站点在localhost使用https解决了这个问题。添加SSL证书并试用它。