Я пытаюсь реализовать ssol-аутентификацию на основе sso, используя spring-security и angular.Здесь есть хороший пример https://www.sylvainlemoine.com/2018/03/29/spring-security-saml2.0-websso-with-angular-client/, который я использую в качестве основы для своего проекта.У меня есть Forgerock OpenAM, работающий на 8090, который служит моим IDP.У меня есть такая же настройка, как указано в примере.
Первый раз, когда вызов для получения токена завершается неудачно с 401, поэтому мой SPA успешно перенаправляет к IDP, и после успешной аутентификации я перенаправлен обратно в мой SPA (через состояние ретрансляции), но как только он вернулсяи он пытается получить токен снова, я снова получаю 401, и это происходит в цикле.Я не могу понять, почему я получаю 401, хотя я успешно прошел аутентификацию.
Я довольно новичок в SSO и saml, любая идея, в чем может быть проблема.Я не могу опубликовать весь код, но вот класс SecurityConfig:
//Credits: Sylvain Lemoine (https://www.sylvainlemoine.com/2018/03/29/spring-security-saml2.0-websso-with-angular-client/)
@Configuration
@EnableWebSecurity
public class SecurityConfig {
/**
* Rest security configuration for /api/
*/
@Configuration
@Order(1)
public static class RestApiSecurityConfig extends WebSecurityConfigurerAdapter {
private static final String apiMatcher = "/api/**";
@Override
protected void configure(HttpSecurity http) throws Exception {
http.addFilterBefore(new JwtAuthenticationFilter(apiMatcher, super.authenticationManager()), UsernamePasswordAuthenticationFilter.class);
http.antMatcher(apiMatcher).authorizeRequests()
.anyRequest()
.authenticated();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) {
auth.authenticationProvider(new JwtAuthenticationProvider());
}
}
/**
* Rest security configuration for /api/
*/
@Configuration
@Order(2)
public static class AuthSecurityConfig extends WebSecurityConfigurerAdapter {
private static final String apiMatcher = "/auth/token";
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.exceptionHandling()
.authenticationEntryPoint(new Http401AuthenticationEntryPoint("SAML2.0 - WEBSSO"));
http.antMatcher(apiMatcher).authorizeRequests()
.anyRequest().authenticated();
}
}
/**
* Saml security config
*/
@Configuration
@Import(SamlSecurityConfig.class)
public static class SamlConfig {
}
}