security安全框架需要的配置——spring.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"
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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值