Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Request execution failure with status code 401 - Failed to register services #9

Open
Alvinchaniago opened this issue Apr 25, 2023 · 3 comments

Comments

@Alvinchaniago
Copy link

Hello,

Thank you for the great tutorial, I have been following this for quite sometime but I am still stuck in the part where SecurityConfig for Discovery Server is defined. I have also changed the code inside the SecurityConfig file according to the latest version in which SecurityFilterChain is used instead of the WebSecurityConfigurerAdapter.

The defaultZone for each service has been updated to incorporate the username and password. Everything inside the application.properties for the services and discovery server is correctly configured. However the 401 error still shows up. What am I missing here? Any help would be greatly appreciated, thank you!

@rubenmaharjan
Copy link

I am getting the same issue. Were you able to solve this problem?

@rubenmaharjan
Copy link

rubenmaharjan commented Jul 26, 2023

It turns out, the SecurityConfig file needs to be in the same directory as the SpringBootApplication file. Inside your SecurityConfig file disable the CSRF.

@Configuration
@EnableWebSecurity
public class SecurityConfig {

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http .csrf((csrf) -> csrf.ignoringRequestMatchers("/eureka/**"));
        return http.build();
    }
}

Configuration Annotation needs to be in the same dir

@suryaschypfer
Copy link

@rubenmaharjan you are a lifesaver, Thanks

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

No branches or pull requests

3 participants