Originally, it was a good idea to study spring cloud. Later, security was introduced for security. Then there were various problems. First, the service could not be registered (solution: after introducing security, the service could not be registered with Eureka), and then the service could not be called,
The error log is as follows:
feign.FeignException$Unauthorized: [401] during [GET] to [ http://eureka-client/client/test ] [ClientService#getClientService()]: [{“timestamp”:”2021-07-08T09:01:18.940+00:00″,”status”:401,”error”:”Unauthorized”,”message”:””,”path”:”/client/test”}]
It’s easy to understand if you read a newspaper error: the call has not been authenticated. This authentication is built-in to security. There are some methods on the Internet, but they are messy and many of them don’t work. Therefore, it’s recommended to turn off the built-in call authentication of security (add logic to the call authentication side to ensure security)
Add a configuration file to the server:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.authorizeRequests().anyRequest().permitAll().and().logout().permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService());
}
}
Due to the version problem, sometimes you need to add additional notes to the startup file
@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})
The test is effective
Read More:
- After introducing security, the service cannot be registered with Eureka
- feign.FeignException$Unauthorized: status 401 reading
- The software licensing service reported that the product SKU is not found
- Spring security failed to log in, error: there is no passwordencoder mapped for the ID “null”
- Django project running service reported an error NameError: name ‘OS’ is not defined
- An error is reported when starting the Remote Access Connection Manager service
- JS uses the and or operator, and an error is reported: uncaught rangeerror: maximum call stack size exceeded
- Connection authorization failure occurred. Reason: local security service non retryable error solution
- Solution to errors reported by TES command in vscode – errors reported by typescript command
- Error reported by gulp: referenceerror: primordials is not defined
- Process of checking the error of connection reset by peer reported by reactor netty
- Solution to the problem of failure to elect leaders when offline service is reported in Nacos
- #An error is reported by the chart map component of renfast framework
- egg.js The frame post request reported an error of invalid CSRF token security verification, which has been solved
- HTTP Error 401.1 – Unauthorized:Access is denied due to invalid credentials
- Handling of expression not in group by key [value] reported by hive on October 12, 2020
- Apache2 cannot be started and an error is reported for apache2.service failed because the control process exited with error code.
- “[warning] failed to retrieve plugin descriptor for caused by Maven security agent settings org.apache.maven . plugins:… “
- MongoDB Error: Failed to start mongod.service: Unit mongod.service is not loaded properly
- WIN7 + IIS7 Service Unavailable HTTP Error 503. The service is unavailable.