小编Mar*_*tin的帖子

Spring Boot Keycloak - 每个请求认证三次

我们将 Spring Boot 2.1.8 与 Undertow 一起使用,并使用 Keycloak 进行身份验证。每个请求都需要身份验证,但 servlet 在 Servlet 管道或过滤器中的不同点调用 Keycloak 进行身份验证三次。

我已经通过 Postman 在 Basic Auth 和 Bearer 令牌的日志中看到了这种行为。

关于为什么会发生这种情况的任何想法?它损害了我们的表现。

钥匙披风配置

@KeycloakConfiguration
public class KeycloakSecurityConfig extends KeycloakWebSecurityConfigurerAdapter {

    private static final String READ_WRITE = "WRITE_USER";
    private static final String READ = "READ_USER";

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
        keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());
        auth.authenticationProvider(keycloakAuthenticationProvider);
    }

    @Bean
    @Override
    protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
        return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception …
Run Code Online (Sandbox Code Playgroud)

java spring-boot undertow keycloak

5
推荐指数
1
解决办法
2000
查看次数

标签 统计

java ×1

keycloak ×1

spring-boot ×1

undertow ×1