安全框架Spring Security 的配置文件 spring-security.xml

<?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"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<!-- 配置 favicon.ico不进行安全拦截-->
<http pattern="/favicon.ico" security="none"/>
<!-- 以下页面不被拦截 -->
<http pattern="/shoplogin.html" security="none"/>
<http pattern="/register.html" security="none"/>
<http pattern="/css/**" security="none"/>
<http pattern="/img/**" security="none"/>
<http pattern="/js/**" security="none"/>
<http pattern="/plugins/**" security="none"/>
<http pattern="/seller/add.do" security="none"/>

<!-- 页面拦截规则 -->
<http use-expressions="false">
<!--access 配置拥有访问权限用户 角色名称 :ROLE_****-->
<intercept-url pattern="/**" access="ROLE_SELLER"/>
<!--默认访问页面 默认跳转页面 一直使用默认跳转页面 错误页面-->
<form-login login-page="/shoplogin.html"
default-target-url="/admin/index.html"
always-use-default-target="true"
authentication-failure-url="/shoplogin.html"/>
<!--csrf 开启防止跨站请求伪造-->
<csrf disabled="true"/>
<headers>
<!--frame页面只能为同源根目录下-->
<frame-options policy="SAMEORIGIN"/>
</headers>
<!--自动生成注销后的地址-->
<logout/>


</http>
<!--认证管理器-->
<authentication-manager>
<authentication-provider user-service-ref="UserDetailService">

</authentication-provider>
</authentication-manager>

<!--引用dubbo服务-->
<dubbo:application name="youlexuan-shop-web"/>
<dubbo:registry address="zookeeper://192.168.30.128:2181"/>
<dubbo:reference interface="com.offcn.sellergoods.service.SellerService" id="sellerService"/>

<!--加载自定义认证类-->
<beans:bean id="UserDetailService" class="com.offcn.service.UserDetailServiceImpl">
<beans:property name="sellerService" ref="sellerService"/>
</beans:bean>

</beans:beans>

猜你喜欢

转载自www.cnblogs.com/gaoshen990816/p/12422291.html
今日推荐