wimdeblauwe / htmx-spring-boot

Spring Boot and Thymeleaf helpers for working with htmx
Apache License 2.0
521 stars 49 forks source link

Spring Security filter chain config #115

Closed taypo closed 5 months ago

taypo commented 7 months ago

The following piece of code, when added breaks my app doing oauth2 login. Is there possibly a way its added to the existing config that's auto configured from application.yml.

@Bean
public SecurityFilterChain filterChain(HttpSecurity http)throws Exception{
    // probably some other configurations here

    var entryPoint = new HxRefreshHeaderAuthenticationEntryPoint();
    var requestMatcher = new RequestHeaderRequestMatcher("HX-Request");
    http.exceptionHandling(exception ->
        exception.defaultAuthenticationEntryPointFor(entryPoint, requestMatcher));
    return http.build();
}

For example, when I prepend the code with

http.authorizeHttpRequests { registry -> registry.requestMatchers("/**").authenticated() }
            .oauth2Login(Customizer.withDefaults())

its starts to work again, but I'm not really sure if I'm still overriding some other defaults. (sorry about the kotlin syntax)

wimdeblauwe commented 6 months ago

Your question is unclear to me. Do you have a small reproducer project I can take a look at?

wimdeblauwe commented 5 months ago

Closing issue because of lacking info.