with ServerHttpSecurity config,can not show more entpoints
application.yml like this
eureka:
instance:
metadata-map:
username: ${SECURITY_USERNAME:admin}
password: ${SECURITY_PASSWORD:admin}
SecurityConfig code:
@Bean
public MapReactiveUserDetailsService userDetailsService() {
UserDetails admin = User.withUsername("admin").password("admin").roles("ADMIN").build();
return new MapReactiveUserDetailsService(admin);
}
@Bean
SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception {
http.httpBasic();
http.formLogin();
http.csrf().disable();
http.logout().disable();
http.authorizeExchange()
.matchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).permitAll()
.matchers(EndpointRequest.toAnyEndpoint()).hasRole(ADMIN_ROLE)//.authenticated()
.pathMatchers(getActuateEndpoint()).hasRole(ADMIN_ROLE)
.pathMatchers("/api/**").permitAll()
.anyExchange().authenticated();
http.headers().cache().disable();
return http.build();
}
then in admin-ui,only show info tabs,i need show other endpoints
You need to expose the actuator endpoints via management.endpoints.web.exposure.include
this config is exist,like management: endpoints: web: #base-path: /actuator exposure: include: "*" endpoint: health: show-details: ALWAYS
if i delete this code ,all endpoints tabs can show /* http.authorizeExchange() .matchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).permitAll() .matchers(EndpointRequest.toAnyEndpoint()).hasRole(ADMIN_ROLE)//.authenticated() .pathMatchers(getActuateEndpoint()).hasRole(ADMIN_ROLE) .pathMatchers("/api/**").permitAll() .anyExchange().authenticated(); */
so i think the hasRole("ADMIN_ROLE") has no affect!!!
only matchers (EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).permitAll()
