<?xml version="1.0" encoding="UTF-8"?> <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.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> <!--需要放行的--> <!--springSecurity框架默认是先获取浏览器标签页网站图标,不放行会报404--> <http pattern="/favicon.ico" security="none"/> <http pattern="/login.html" security="none"/> <!-- /** 是代表不管多少层目录都匹配,一个*只代表一层目录--> <http pattern="/css/**" security="none"/> <http pattern="/img/**" security="none"/> <http pattern="/js/**" security="none"/> <http pattern="/plugins/**" security="none"/> <!--use-expressions 是否使用默认表达式,默认为true--> <http use-expressions="false"> <!--指定intercept-url访问所应有的权限,intercept-url是浏览器的地址栏的路径--> <intercept-url pattern="/**" access="ROLE_USE"/> <!-- login-page —— 登录页面 default-target-url —— 登录成功跳转的页面 always-use-default-target —— 是否一直使用这个登录成功的页面 authentication-failure-url —— 登录失败跳转的页面 注意:路径前面一定要加 / !!!!!!!!!!!! --> <form-login login-page="/login.html" default-target-url="/admin/index.html" always-use-default-target="true" authentication-failure-url="/login.html"/> <!--关闭跨域请求--> <csrf disabled="true"/> <headers> <!-- frame是html页面 用来划分多个页面在同一页面上所占比例的标签 deny:表示该页面不允许在 frame 中展示,即便是在相同域名的页面中嵌套也不允许。 sameorigin:表示该页面可以在相同域名页面的 frame 中展示。 allow-from uri:表示该页面可以在指定来源的 frame 中展示。 --> <frame-options policy="SAMEORIGIN"/> </headers> <!--注销需要用到的 <a href="../logout" >点击</a>--> <logout/> </http> <!--身份认证管理器--> <authentication-manager> <authentication-provider><!--提供者--> <user-service> <user name="admin" password="123" authorities="ROLE_USE"/> </user-service> </authentication-provider> </authentication-manager> </beans:beans>
security安全框架需要的配置——spring.xml配置
最新推荐文章于 2021-07-21 10:46:18 发布