【发布时间】:2014-10-10 02:31:11
【问题描述】:
我正在使用 Spring Security 通过以下配置来保护我的应用程序,以尝试显示 Spring 默认登录页面:
spring-security.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<http auto-config="true">
<intercept-url pattern="/**" access="ROLE_USER" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="test.account" password="123456" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
我的问题是所有资源都已成功通过身份验证,除了始终向公众开放的 Angular 文件 (localhost:8080/#/notification)。
编辑 1:
我尝试在 Jetty 服务器上运行上述 spring 安全配置,效果很好。仅在将<sessions-enabled>true</sessions-enabled> 添加到 appengine-web.xml 后,使用 Google AppEngine 时才会出现此问题。
提前谢谢你。
【问题讨论】:
-
那是因为该请求永远不会到达服务器。 hashbang 完全在客户端解决。您可能需要保护的是与该 hashbang 关联的视图,因此当您尝试获取该部分视图时,它会受到您的安全策略的保护。
-
@EdwinDalorzo 感谢您的帮助,保护我的 /index.html 页面的最佳做法是什么?
-
Spring 依赖于 MVC 在服务器端这一事实。但是 Angukar 将所有 MVC 转移到客户端。
-
@QhadR 那么有没有办法使用 Spring security 来保护它?
-
请检查问题更新
标签: java angularjs spring google-app-engine spring-security