繁体   English   中英

无法使用Spring Security保护AngularJS页面

[英]Can not secure AngularJS page using Spring Security

我正在使用Spring Security通过以下配置保护我的应用程序的安全,以尝试显示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时出现。

先感谢您。

我已经能够使用web.xml文件的<security-constraint>属性在Google AppEngine上使用Spring MVC保护静态文件。

例:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Public Area</web-resource-name>
        <url-pattern>/xyz</url-pattern>
        <url-pattern>/images/*</url-pattern>
        <url-pattern>/yyz/*</url-pattern>
        <url-pattern>*.xml</url-pattern>
    </web-resource-collection>
</security-constraint>

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Protected Area</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>*</role-name>
    </auth-constraint>
</security-constraint>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM