【发布时间】:2018-04-22 16:22:31
【问题描述】:
通过在 liferay 中为休息服务实施 Spring 基本授权,我面临一个非常尴尬的问题。 实际上,当我在本地计算机上测试应用程序时,配置工作得很好。
当我在我们的测试服务器上部署应用程序时,问题就出现了。 服务器总是返回 401 未授权访问,但从未到达授权提供者。
通过调试,我注意到请求在到达 BasicAuthenticationFilter 时不包含带有凭据的标头(header = null):
if(header != null && header.startsWith("Basic "))
通过分析浏览器的网络流量,Authorization 标头就在那里。
这是我的安全配置:
<http pattern="/*" security="none"/>
<!-- urls that need authentication and roles -->
<http use-expressions="true" >
<intercept-url pattern="/myrest/url/**" access="hasAnyRole('myrole')" />
<http-basic/>
</http>
<!-- AuthenticationManager / Provider that checks the authentication against Liferay -->
<beans:bean id="myCustomAuthorizationProvider"
class="myCustomAuthorizationProvider">
<beans:constructor-arg ref="myUsersDao"/>
<beans:constructor-arg ref="MyRolesDao"/>
</beans:bean>
<authentication-manager>
<authentication-provider ref="myCustomAuthorizationProvider"/>
</authentication-manager>
我将不胜感激。
【问题讨论】:
-
您使用的是什么版本的 Liferay?
标签: rest spring-security liferay basic-authentication