Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Security filter chain config #115

Open
taypo opened this issue Apr 25, 2024 · 1 comment
Open

Spring Security filter chain config #115

taypo opened this issue Apr 25, 2024 · 1 comment

Comments

@taypo
Copy link

taypo commented Apr 25, 2024

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants