Ich habe durch die Schritte in dem Dokument gegangen -Okta-api -Ausgabe mit Spring-Sicherheit SAML mit CSRF
https://developer.okta.com/blog/2017/03/16/spring-boot-saml#run-the-app-and-login-with-okta
Alles funktioniert gut und ich sehe SAML-Antwort bekommen erzeugt und reditection geschieht Anwendung von OKTA, aber wenn die Anfrage die Anwendung erreicht, bekomme ich diesen Fehler-
Typ = verboten, Status = 403). Ungültiges CSRF-Token 'null' wurde unter der Anforderungsparameter '_csrf' oder der Header 'X-CSRF-TOKEN' gefunden.
Ich habe versucht, csrf zu deaktivieren, aber dann geht es in Endlosschleife mit SAML-Umleitung.
Hier SecurityConfiguration.java-
package com.example;
import static org.springframework.security.extensions.saml2.config.SAMLConfigurer.saml;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@EnableWebSecurity
@Configuration
@EnableGlobalMethodSecurity(securedEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Value("${security.saml2.metadata-url}")
String metadataUrl;
@Value("${server.ssl.key-alias}")
String keyAlias;
@Value("${server.ssl.key-store-password}")
String password;
@Value("${server.port}")
String port;
@Value("${server.ssl.key-store}")
String keyStoreFilePath;
@Override
protected void configure(final HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/saml*").permitAll()
.anyRequest().authenticated()
.and()
.apply(saml())
.serviceProvider()
.keyStore()
.storeFilePath("saml/keystore.jks")
.password(this.password)
.keyname(this.keyAlias)
.keyPassword(this.password)
.and()
.protocol("https")
.hostname(String.format("%s:%s", "10.200.10.10", this.port))
.basePath("/")
.and()
.identityProvider()
.metadataFilePath(this.metadataUrl);
}
}
Jeder Vorschlag ist willkommen.
Warum muss die URL nur mit/saml/sso angehängt werden? Wenn ich die URL ändere, sagen wir/saml/xyz. Ich bekomme 403 Fehler – theLearner
Da dieser Wert in SamlFilter in der 'SAMLConfigurer'-Klasse fest codiert ist: https://github.com/spring-projects/spring-security-saml-dsl/blob/master/spring-security- saml-dsl/src/main/java/org/springframework/sicherheit/erweiterungen/saml2/config/SAMLConfigurer.java # L265 –