Skip to content

Commit

Permalink
remove filter chain reference to endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhao99 committed Jan 8, 2024
1 parent be2209f commit f3a3ee3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,36 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.exception.JDBCConnectionException;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

@Component("backend-and-db-smoke-test")
@Endpoint
@Slf4j
@RequiredArgsConstructor
public class BackendAndDatabaseHealthIndicator implements HealthIndicator {
private final FeatureFlagRepository _ffRepo;
private final OktaRepository _oktaRepo;
public static final String ACTIVE_LITERAL = "ACTIVE";
private final FeatureFlagRepository _ffRepo;
private final OktaRepository _oktaRepo;
public static final String ACTIVE_LITERAL = "ACTIVE";

@Override
public Health health() {
try {
_ffRepo.findAll();
String oktaStatus = _oktaRepo.getApplicationStatusForHealthCheck();
@Override
public Health health() {
try {
_ffRepo.findAll();
String oktaStatus = _oktaRepo.getApplicationStatusForHealthCheck();

if (!ACTIVE_LITERAL.equals(oktaStatus)) {
log.info("Okta status didn't return ACTIVE, instead returned " + oktaStatus);
return Health.down().build();
}
if (!ACTIVE_LITERAL.equals(oktaStatus)) {
log.info("Okta status didn't return ACTIVE, instead returned " + oktaStatus);
return Health.down().build();
}

return Health.up().build();
} catch (JDBCConnectionException e) {
return Health.down().build();
// Okta API call errored
} catch (ApiException e) {
log.info(e.getMessage());
return Health.down().build();
}
return Health.up().build();
} catch (JDBCConnectionException e) {
return Health.down().build();
// Okta API call errored
} catch (ApiException e) {
log.info(e.getMessage());
return Health.down().build();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gov.cdc.usds.simplereport.config;

import com.okta.spring.boot.oauth.Okta;
import gov.cdc.usds.simplereport.api.heathcheck.BackendAndDatabaseHealthIndicator;
import gov.cdc.usds.simplereport.service.model.IdentityAttributes;
import gov.cdc.usds.simplereport.service.model.IdentitySupplier;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -58,8 +57,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.permitAll()
.requestMatchers(EndpointRequest.to(InfoEndpoint.class))
.permitAll()
.requestMatchers(EndpointRequest.to(BackendAndDatabaseHealthIndicator.class))
.permitAll()
// Patient experience authorization is handled in PatientExperienceController
// If this configuration changes, please update the documentation on both sides
.requestMatchers(HttpMethod.POST, WebConfiguration.PATIENT_EXPERIENCE)
Expand Down

0 comments on commit f3a3ee3

Please sign in to comment.