下面列出了怎么用org.springframework.boot.actuate.health.HealthEndpoint的API类实例代码及写法,或者点击链接到github查看源代码。
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.csrf()
.disable();
http
.requestMatcher(new ActuatorRequestMatcher())
.authorizeRequests()
.requestMatchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).authenticated()
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasAnyAuthority(DefaultPrivileges.ACCESS_ADMIN)
.and().httpBasic();
}
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.csrf()
.disable();
http
.requestMatcher(new ActuatorRequestMatcher())
.authorizeRequests()
.requestMatchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).authenticated()
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasAnyAuthority(DefaultPrivileges.ACCESS_ADMIN)
.and().httpBasic();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.csrf()
.disable();
http
.requestMatcher(new ActuatorRequestMatcher())
.authorizeRequests()
.requestMatchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).authenticated()
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasAnyAuthority(DefaultPrivileges.ACCESS_ADMIN)
.and().httpBasic();
}
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.csrf()
.disable();
http
.requestMatcher(new ActuatorRequestMatcher())
.authorizeRequests()
.requestMatchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).authenticated()
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasAnyAuthority(DefaultPrivileges.ACCESS_ADMIN)
.and().httpBasic();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.requestMatcher(EndpointRequest.toAnyEndpoint())
.authorizeRequests()
.requestMatchers(EndpointRequest.to(HealthEndpoint.class)).permitAll()
.anyRequest().authenticated()
.and()
.httpBasic();
}
MetricsHealthController(
MeterRegistry meterRegistry,
HealthEndpoint healthEndpoint,
HealthStatusHttpMapper statusMapper,
CollectorRegistry collectorRegistry
) {
this.meterRegistry = meterRegistry;
this.healthEndpoint = healthEndpoint;
this.statusMapper = statusMapper;
this.collectorRegistry = collectorRegistry;
}
public ActuatorCommand(ApplicationContext applicationContext, Environment environment,
SshShellProperties properties, SshShellHelper helper,
@Lazy AuditEventsEndpoint audit, @Lazy BeansEndpoint beans,
@Lazy ConditionsReportEndpoint conditions,
@Lazy ConfigurationPropertiesReportEndpoint configprops, @Lazy EnvironmentEndpoint env,
@Lazy HealthEndpoint health,
@Lazy HttpTraceEndpoint httptrace, @Lazy InfoEndpoint info, @Lazy LoggersEndpoint loggers,
@Lazy MetricsEndpoint metrics,
@Lazy MappingsEndpoint mappings, @Lazy ScheduledTasksEndpoint scheduledtasks,
@Lazy ShutdownEndpoint shutdown,
@Lazy ThreadDumpEndpoint threaddump) {
this.applicationContext = applicationContext;
this.environment = environment;
this.properties = properties;
this.helper = helper;
this.audit = audit;
this.beans = beans;
this.conditions = conditions;
this.configprops = configprops;
this.env = env;
this.health = health;
this.httptrace = httptrace;
this.info = info;
this.loggers = loggers;
this.metrics = metrics;
this.mappings = mappings;
this.scheduledtasks = scheduledtasks;
this.shutdown = shutdown;
this.threaddump = threaddump;
}
@Override
public void configure(HttpSecurity http) throws Exception {
// The health endpoint should always be exposed without auth.
http.requestMatcher(EndpointRequest.to(HealthEndpoint.class))
.authorizeRequests()
.anyRequest()
.permitAll();
}
@Bean
@ConditionalOnMissingBean
public ActuatorHealthDimension createHealthDimension(HealthEndpoint endpoint) {
return new ActuatorHealthDimension(endpoint);
}
public ActuatorHealthDimension(HealthEndpoint endpoint) {
this.endpoint = endpoint;
}
@Bean
public ActuatorHealthDimension createHealthDimension(HealthEndpoint endpoint) {
return new ActuatorHealthDimension(endpoint);
}
/**
* @return whether `health` command is available
*/
public Availability healthAvailability() {
return availability("health", HealthEndpoint.class);
}
HealthCommand(@Value("${sshd.system.command.roles.health}") String[] systemRoles, HealthEndpoint healthEndpoint) {
super(systemRoles);
this.healthEndpoint = healthEndpoint;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
HttpSecurity httpSecurity = http.authenticationProvider(authenticationProvider())
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.csrf().disable();
if (restAppProperties.getCors().isEnabled()) {
httpSecurity.apply(new PropertyBasedCorsFilter(restAppProperties));
}
// Swagger docs
if (isSwaggerDocsEnabled()) {
httpSecurity
.authorizeRequests()
.antMatchers("/docs/**").permitAll();
} else {
httpSecurity
.authorizeRequests()
.antMatchers("/docs/**").denyAll();
}
httpSecurity
.authorizeRequests()
.requestMatchers(EndpointRequest.to(InfoEndpoint.class, HealthEndpoint.class)).authenticated()
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasAnyAuthority(SecurityConstants.ACCESS_ADMIN);
// Rest API access
if (isVerifyRestApiPrivilege()) {
httpSecurity
.authorizeRequests()
.anyRequest()
.hasAuthority(SecurityConstants.PRIVILEGE_ACCESS_REST_API).and ().httpBasic();
} else {
httpSecurity
.authorizeRequests()
.anyRequest()
.authenticated().and().httpBasic();
}
}