SaiUpadhyayula / spring-boot-microservices

This repository contains the latest source code of th spring-boot-microservices tutorial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Alvinchaniago opened this issue · comments

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!

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

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

@rubenmaharjan you are a lifesaver, Thanks