From f3a3ee3bbd34b4280562dd39a001a7b6576a98ee Mon Sep 17 00:00:00 2001 From: Bob Zhao Date: Mon, 8 Jan 2024 10:11:14 -0500 Subject: [PATCH] remove filter chain reference to endpoint --- .../BackendAndDatabaseHealthIndicator.java | 42 +++++++++---------- .../config/SecurityConfiguration.java | 3 -- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/backend/src/main/java/gov/cdc/usds/simplereport/api/heathcheck/BackendAndDatabaseHealthIndicator.java b/backend/src/main/java/gov/cdc/usds/simplereport/api/heathcheck/BackendAndDatabaseHealthIndicator.java index 8db7168706..0a8cb830b2 100644 --- a/backend/src/main/java/gov/cdc/usds/simplereport/api/heathcheck/BackendAndDatabaseHealthIndicator.java +++ b/backend/src/main/java/gov/cdc/usds/simplereport/api/heathcheck/BackendAndDatabaseHealthIndicator.java @@ -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(); } + } } diff --git a/backend/src/main/java/gov/cdc/usds/simplereport/config/SecurityConfiguration.java b/backend/src/main/java/gov/cdc/usds/simplereport/config/SecurityConfiguration.java index 07a737850a..15fdeee263 100644 --- a/backend/src/main/java/gov/cdc/usds/simplereport/config/SecurityConfiguration.java +++ b/backend/src/main/java/gov/cdc/usds/simplereport/config/SecurityConfiguration.java @@ -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; @@ -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)