[英]AngularJS and Spring Security. How to handle AngularJS Urls with Spring Security
让我解释一下我的问题。 我已经在AngularJS中实现了一个网站,该网站的访问方式如下:
http://localhost:8080/example/resources/#/
在这里我们可以调用不同的页面,例如登录页面:
http://localhost:8080/example/resources/#/login
管理页面:
http://localhost:8080/example/resources/#/admin
用户页面:
http://localhost:8080/example/resources/#/user
现在,我在示例中实现了spring安全性,以捕获每个调用并检查其是否具有ROLE_USER特权。 到目前为止,到目前为止,我已经在Spring安全上下文文件中完成了以下配置:
<security:http create-session="stateless" entry-point-ref="restAuthenticationEntryPoint"
authentication-manager-ref="authenticationManager">
<security:custom-filter ref="customRestFilter" position="BASIC_AUTH_FILTER" />
<security:intercept-url pattern="/**" access="ROLE_USER" />
</security:http>
如果用户具有正确的ROLES,此配置将检查每个调用的URL,并且工作正常,并抛出401未经授权页面。
我遇到的问题是,当我将登录页面设置为所有人均可访问时,我将通过以下方式进行操作:
<security:http create-session="stateless" entry-point-ref="restAuthenticationEntryPoint"
authentication-manager-ref="authenticationManager">
<security:custom-filter ref="customRestFilter" position="BASIC_AUTH_FILTER" />
<security:intercept-url pattern="/login**" access="ROLE_ANONYMOUS" />
<security:intercept-url pattern="/**" access="ROLE_USER" />
</security:http>
但我不知道为什么Spring Security无法捕获此URL。 也许Angular对URL进行不同的管理。
最后,我尝试删除<security:intercept-url pattern="/**" access="ROLE_USER" />
并仅授予/ login **访问ROLE_USER的权限,但未找到此页面。 有人知道这里会发生什么吗?
提前致谢!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.