安全框架配置文件(spring-security.xml)

Posted hubert-dzl

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安全框架配置文件(spring-security.xml)相关的知识,希望对你有一定的参考价值。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:security="http://www.springframework.org/schema/security"
       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">
    <!--对登录和失败页面放行-->
    <security:http pattern="/login.jsp" security="none"></security:http>
    <security:http pattern="/error.jsp" security="none"></security:http>
    <security:http pattern="/favicon.ico" security="none"></security:http>
    <security:http pattern="/css/**" security="none"></security:http>
    <security:http pattern="/img/**" security="none"></security:http>
    <security:http pattern="/plugins/**" security="none"></security:http>

    <security:http auto-config="true" use-expressions="false">
        <security:intercept-url pattern="/**" access="ROLE_USER"/>

        <!--页面的具体跳转-->
        <security:form-login login-page="/login.jsp"
                             login-processing-url="/login"
                             default-target-url="/index.jsp"
            ></security:form-login>

        <security:csrf disabled="true"/>
        <!--退出-->
        <security:logout invalidate-session="true" logout-url="/logout" logout-success-url="/login.jsp"/>
    </security:http>
    <!--配置默认可以登录的账户密码-->
    <security:authentication-manager>
        <security:authentication-provider>
            <security:user-service>
                <security:user name="ding" password="noopding" authorities="ROLE_USER" />
            </security:user-service>
        </security:authentication-provider>
    </security:authentication-manager>
</beans>

  

以上是关于安全框架配置文件(spring-security.xml)的主要内容,如果未能解决你的问题,请参考以下文章

spring-security框架

Spring-Security自定义登录页&inMemoryAuthentication验证

Tomcat8+Spring-Security 启用安全通道(https)的一步步实现

使用spring-security更改方法调用的安全性上下文

Spring-Security

web应用安全框架选型:Spring Security与Apache Shiro