Spring security logout Handhabung

Laut Spring Security 4.0.0 Dokument:

4.2.4 Logout Umgang

Den logout-element fügt Unterstützung für das Abmelden des Benutzers durch navigieren zu einem
bestimmte URL. Die default-logout-URL /logout, aber Sie können es
etwas anderes über das logout-url-Attribut. Mehr Informationen auf
anderen verfügbaren Parametern finden Sie im namespace Anhang.

Jedoch nach folgenden Sicherheits-Einstellung in den doc, der URL /logout nicht zeigen logout-Seite. Stattdessen zeigt er

Spring security logout Handhabung

Im Gegenteil, der URL /login funktioniert.

Spring security logout Handhabung

Das folgende ist meine Einstellung:

Spring Framework 4.1.6
Spring Security 4.0.0

Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    <display-name>Test8</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/security-config.xml</param-value>
    </context-param>


</web-app>

security-config.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-3.0.xsd
           http://www.springframework.org/schema/security
           http://www.springframework.org/schema/security/spring-security.xsd">
    <http>
        <intercept-url pattern="/**" access="hasRole('USER')" />
        <form-login />
        <logout />
    </http>

    <authentication-manager>
        <authentication-provider>
            <user-service>
                <user name="aaa" password="111" authorities="ROLE_USER, ROLE_ADMIN" />
                <user name="bbb" password="222" authorities="ROLE_USER" />
            </user-service>
        </authentication-provider>
    </authentication-manager>

</beans:beans>
codeproject.com/Tips/521847/Logout-Spring-s-LogoutFilter kann dies helfen?
Ich bin mit dem gleichen Problem in meiner Anwendung. Es funktionierte auch mit der version 3.2.7, und da habe ich ein Upgrade auf 4.0.1 gibt es kein mapping für /logout-url nicht mehr.

InformationsquelleAutor cht | 2015-04-09

Schreibe einen Kommentar