繁体   English   中英

Spring安全性不适用于angularJS

[英]Spring security doesn't work with angularJS

我用java和angularJS编写了一个应用程序。 现在我想添加Spring Security但是Spring没有使用angular的路径。

以下是安全属性:

<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" use-expressions="true">

        <intercept-url pattern="/login" access="permitAll" />
        <intercept-url pattern="/rest#/registration" access="permitAll" />
        <intercept-url pattern="/rest**" access="hasRole('ROLE_USER')" />

        <form-login login-page="/login" 
            default-target-url="/rest"
            authentication-failure-url="/login?error" username-parameter="username"
            password-parameter="password" />
        <logout logout-success-url="/login?logout" />
    </http>

    <authentication-manager>
        <authentication-provider user-service-ref="myUserDetailsService">
            <password-encoder hash="md5" />
        </authentication-provider>
    </authentication-manager>

</beans:beans>

Spring阻止了所​​有由“/ rest”启动的路径,因此我无法打开注册页面。

Spring在服务器上,它确实知道#paths,它只与客户端有关。 您需要做的是:1。使用角度来隐藏视图。 (基于来自服务器的用户角色)2。使用spring来保护ajax调用。

暂无
暂无

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

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