0

i have problem with Keycloack 19 implementation for SpringBoot 3. I have checked some tutorials and every thing seems OK, but i get error beacause missing implementation of initi(B) in SecurityConfigurer.

  <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-spring-security-adapter</artifactId>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.keycloak.bom</groupId>
                <artifactId>keycloak-adapter-bom</artifactId>
                <version>${keycloakVersion}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

And, here is my implementation

@Configuration
@EnableWebSecurity
@RequiredArgsConstructor
public class KeycloakWebSecurityConfig extends KeycloakWebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        super.configure(http);
        http.csrf()
                .disable()
                .authorizeRequests()
                .anyRequest()
                .authenticated();
        http.csrf().disable();
    }
    @Autowired
    public void configrueGlobal(AuthenticationManagerBuilder auth) throws Exception {
        KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider();
        keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());
        auth.authenticationProvider(keycloakAuthenticationProvider);
    }
    @Bean
    @Override
    protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
       return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());    }
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder(12);
    }
}

[![IJ Error][1]][1] [1]: https://i.stack.imgur.com/JEHPR.png

JustM
  • 98
  • 2
  • 10
  • Yes exactly, that's it ! I use Bealdung tutorial with OAuth2 client https://www.baeldung.com/spring-boot-keycloak – JustM Jan 13 '23 at 07:20
  • This tutorial is targeting spring-boot 2.x and OAuth2 **client** (Thymeleaf or other server-side rendering framework). It is adapted to neither **resource-servers** (REST APIs) nor spring-boot 3. One positive point is it does not use deprecated Keycloak adapters for spring. – ch4mp Jan 13 '23 at 07:47

0 Answers0