spring-boot-admin icon indicating copy to clipboard operation
spring-boot-admin copied to clipboard

with ServerHttpSecurity config,can not show more entpoints

Open AaronChen2012 opened this issue 8 years ago • 3 comments

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

AaronChen2012 avatar Aug 27 '18 06:08 AaronChen2012

You need to expose the actuator endpoints via management.endpoints.web.exposure.include

joshiste avatar Aug 27 '18 07:08 joshiste

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!!!

AaronChen2012 avatar Aug 27 '18 07:08 AaronChen2012

only matchers (EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).permitAll() image

AaronChen2012 avatar Aug 27 '18 08:08 AaronChen2012