У меня есть работающее приложение Spring Boot 1.x, настроенное с другим портом управления и безопасностью (Basic Auth).После перехода на Spring 2.1 он больше не работает.
См. Код:
@ ManagementContextConfiguration открытый класс ManagementConfig {
@EnableWebSecurity
@Order(SecurityProperties.BASIC_AUTH_ORDER)
static class SecurityConfig extends WebSecurityConfigurerAdapter {
public SecurityConfig() {
super(true); // disable defaults
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
auth.inMemoryAuthentication()
.withUser("admin")
.password(encoder.encode("admin"))
.roles(Collections.emptyList().toArray(new String[]{}));
}
@Override
protected void configure(HttpSecurity http) throws Exception {
RequestMatcher matcher = new AntPathRequestMatcher("/**");
http
.authorizeRequests()
.requestMatchers(matcher).authenticated();
}
}
}
Мой spring.factories содержит
org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration=\
com.test.config.ManagementConfig
Во время отладки я вижу, что экземпляр SecurityConfig создан, но не вызван метод configure () (как я вижу, в Spring Boot 1.x после создания ManagementConfig был вызван постпроцессор).
Мой application.yml содержит:
management.server:
address: localhost
port: 18543
security:
enabled: true
Проблема в том, что теперь я могу получить доступ к любой конечной точке управления с помощью простого
curl http://localhost:18543/info