I have configured my own in-memory authentication config and my application can register itself at Spring Boot Admin Server and the server gets the right credentials, but it still gets an unauthorized response from my application. If I enter the credentials in my browser then it works.
@Configuration
@Order(2)
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {
@Value("${spring.boot.admin.client.instance.metadata.user.name:actuator}")
private String actuatorName;
@Value("${spring.boot.admin.client.instance.metadata.user.password:secret}")
private String actuatorPassword;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser(actuatorName).password("{noop}" + actuatorPassword).authorities("ACTUATOR");
}
@Override
public void configure(HttpSecurity http) throws Exception {
http
.antMatcher("/actuator/**")
.authorizeRequests()
.anyRequest().hasAuthority("ACTUATOR")
.and()
.httpBasic();
}
}
The difference between browser request that works and the Spring-Boot-Admin request that results in 401 is that BasicAuthenticationFilter gets a header in the browser attempt but in Spring-Boot-Admin attempt BasicAuthenticationFilter don't read any header and results in an anonymous user.
Any ideas?