Текущее поведение следующее: при доступе к http://localhost:8080/api/logout (адрес выхода из системы) подключенный пользователь очень кратко перенаправляется на страницу загрузки Okta, а затем обратно туда, где он начался (панель управления приложением), что означает, что отключения не произошло. Насколько я понимаю, это предполагает, что выход из системы работает на стороне Spring, но не на стороне Okta. Пожалуйста, поправьте меня, если я ошибаюсь.
Я просмотрел несколько страниц справки Okta, среди которых Выйти пользователей | Okta Developer и попросил агентов искусственного интеллекта, но, к сожалению, я не могу заставить его работать.
Вот файл конфигурации Spring Security:
Код: Выделить всё
package com.cohortis.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
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.configurers.AbstractHttpConfigurer;
import org.springframework.security.saml2.provider.service.registration.InMemoryRelyingPartyRegistrationRepository;
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration;
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrations;
import org.springframework.security.web.SecurityFilterChain;
import static org.springframework.security.config.Customizer.withDefaults;
@Configuration
@EnableWebSecurity
@EnableMethodSecurity
public class SecurityConfig {
@Bean
@Profile("prod")
public InMemoryRelyingPartyRegistrationRepository prodRelyingPartyRegistrationRepository() {
RelyingPartyRegistration registration = RelyingPartyRegistrations
.fromMetadataLocation("classpath:metadata/metadata-idp.xml")
.registrationId("okta")
.entityId("{baseUrl}/saml2/service-provider-metadata/{registrationId}")
.build();
return new InMemoryRelyingPartyRegistrationRepository(registration);
}
@Bean
@Profile({"dev", "test"})
public InMemoryRelyingPartyRegistrationRepository devRelyingPartyRegistrationRepository() {
RelyingPartyRegistration registration = RelyingPartyRegistrations
.fromMetadataLocation("classpath:metadata/metadata-idp-dev.xml")
.registrationId("okta")
.entityId("{baseUrl}/saml2/service-provider-metadata/{registrationId}")
.build();
return new InMemoryRelyingPartyRegistrationRepository(registration);
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/saml2/**", "/error", "/api/userIsConnected").permitAll()
.anyRequest().authenticated())
.saml2Login(login -> login
.loginPage("/saml2/authenticate?registrationId=okta")
.defaultSuccessUrl("/api/loginSuccessful", true))
.saml2Logout(withDefaults())
.logout(logout -> logout
.logoutUrl("/api/logout")
.logoutSuccessUrl("/")
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID"));
return http.build();
}
}
header 1
header 2
Включить единый выход
[x] Разрешить приложению инициировать единый выход
URL единого выхода
http://localhost:8080/logout/saml2/slo
SP Issuer
http://localhost:8080/saml2/service-pro ... adata/okta
Подписанные запросы
[ ] Проверка запросов SAML с помощью сертификатов подписи
Все еще на Okta веб-сайте, я загрузил свой открытый ключ (который находится в папке ресурсов приложения Spring вместе с закрытым ключом).
Если у вас есть идеи, как это исправить, дайте мне знать. И извините за нуба…
Огромное спасибо за помощь
Подробнее здесь: https://stackoverflow.com/questions/798 ... -from-okta
Мобильная версия