2016-03-29 8 views
0

ich im folgenden Frühling Sicherheitskonfiguration hat:Feder Sicherheit ignoriert Authentifizierung ausfall url

<security:http auto-config="true" use-expressions="false" entry-point-ref="httpStatusEntryPoint"> 
     <security:custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrentSessionFilter"/> 

     <security:form-login 
       authentication-success-handler-ref="authenticationSuccessHandler" 
       authentication-failure-url="/api/loginFailed" 
     /> 

     <security:intercept-url pattern="/api/**"/> 
     <security:anonymous enabled="false"/> 
     <security:logout logout-url="/logout" delete-cookies="JSESSIONID,sessionId" 
         success-handler-ref="logoutSuccessHandler" 
     /> 
     <security:csrf disabled="true"/> 

     <security:session-management session-authentication-strategy-ref="sessionAuthenticationStrategy"/> 

I-Eingang falsches Passwort und nach Ausführung verläuft nicht in

@RequestMapping(value = "/loginFailed", method = RequestMethod.GET) 
@ResponseStatus(HttpStatus.UNAUTHORIZED) 
public String loginError(HttpServletRequest httpServletRequest) { 
    return getErrorMessage(httpServletRequest, SPRING_SECURITY_LAST_EXCEPTION_KEY); 
} 

Was ich falsch gemacht ?

Antwort

0

ist hier die Frage und Lösung:

auf Ihrer Konfigurations Basierend:

<security:intercept-url pattern="/api/**"/> 

Alle Pfade unterhalb des api Pfad befestigt sind. Dazu gehört auch die authenticationSuccessHandler Konfiguration gemäß Ihrer aktuellen Konfiguration :.

<security:form-login 
       authentication-success-handler-ref="authenticationSuccessHandler" 
       authentication-failure-url="/api/loginFailed" 
     /> 

Spring Security ist in der Tat zurück zu /api/loginFailed auf fehlgeschlagene Anmeldeversuche Umleiten aber da dies auch eine geschützte Ressource ist, wird eine andere Umleitung an den Authentifizierungseintrittspunkt passieren. Sie können dies mithilfe der Browser-Entwicklungstools auf der Registerkarte Netzwerkaktivität überprüfen.

Sie müssen sicherstellen, dass authentication-failure-url auf einem ungesicherten Endpunkt ist. Zum Beispiel /loginFailed.

So diese Konfiguration funktioniert:

<security:intercept-url pattern="/api/**"/> 

<security:form-login 
       authentication-success-handler-ref="authenticationSuccessHandler" 
       authentication-failure-url="/loginFailed" 
     /> 
+0

es mit api – gstackoverflow

+0

/api nicht erteilen wird/loginFailed nach der Anmeldung verfügbar – gstackoverflow

Verwandte Themen