From 93872cda75a7be5dd420930342cf1bc51c9ae307 Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Wed, 10 Jul 2024 12:29:35 -0700 Subject: [PATCH] chore(deps): remove Java inbuilt docker compose for db (#1376) Co-authored-by: Ricardo Campos --- backend/README.md | 7 +-- backend/pom.xml | 12 ------ .../config/SecurityConfig.java | 2 - .../config/SecurityConfigDev.java | 43 ------------------- .../security/UserAuthenticationHelper.java | 18 -------- .../src/main/resources/application.properties | 2 - .../src/main/resources/docker-compose-dev.yml | 19 -------- 7 files changed, 1 insertion(+), 102 deletions(-) delete mode 100644 backend/src/main/java/ca/bc/gov/backendstartapi/config/SecurityConfigDev.java delete mode 100644 backend/src/main/resources/docker-compose-dev.yml diff --git a/backend/README.md b/backend/README.md index 9c6a9ab16..284da7cf3 100644 --- a/backend/README.md +++ b/backend/README.md @@ -78,11 +78,6 @@ If you want to have all frontend, backend and database, just run: docker compose up backend -d ``` -But if you can see only the backend and databse, run from the `backend` directory: -```sh -./mvnw spring-boot:run -Pdocker-compose -Dspring-boot.run.profiles=docker-compose -``` - If you need to change the code, no problem. Once you hit Ctrl+S keys the service will be restarted! Enjoy @@ -124,4 +119,4 @@ pass. ## Getting help As mentioned, we're here to help. Feel free to start a conversation -on Rocket chat or ask a question on Stackoverflow. \ No newline at end of file +on Rocket chat or ask a question on Stackoverflow. diff --git a/backend/pom.xml b/backend/pom.xml index 996cabb51..069822437 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -99,11 +99,6 @@ - - - - docker-compose - @@ -152,13 +147,6 @@ org.springframework.boot spring-boot-starter-actuator - - org.springframework.boot - spring-boot-docker-compose - 3.3.0 - true - test - diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/config/SecurityConfig.java b/backend/src/main/java/ca/bc/gov/backendstartapi/config/SecurityConfig.java index f917d2577..1aba4378e 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/config/SecurityConfig.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/config/SecurityConfig.java @@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; import org.springframework.core.convert.converter.Converter; import org.springframework.http.HttpMethod; import org.springframework.security.authentication.AbstractAuthenticationToken; @@ -27,7 +26,6 @@ @Configuration @EnableWebSecurity @EnableMethodSecurity -@Profile("!docker-compose") public class SecurityConfig { @Value("${spring.security.oauth2.resourceserver.jwt.jwk-set-uri}") diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/config/SecurityConfigDev.java b/backend/src/main/java/ca/bc/gov/backendstartapi/config/SecurityConfigDev.java deleted file mode 100644 index 0baa0dff6..000000000 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/config/SecurityConfigDev.java +++ /dev/null @@ -1,43 +0,0 @@ -package ca.bc.gov.backendstartapi.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.http.HttpMethod; -import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; -import org.springframework.security.web.SecurityFilterChain; - -/** This class contains all configurations for a dev security. */ -@Configuration -@EnableMethodSecurity(prePostEnabled = false) -@Profile("docker-compose") -public class SecurityConfigDev { - - /** - * Filters a request to add security checks and configurations. - * - * @param http instance of HttpSecurity containing the request. - * @return SecurityFilterChain with allowed endpoints and all configuration. - * @throws Exception due to bad configuration possibilities. - */ - @Bean - public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - http.cors(AbstractHttpConfigurer::disable) - .csrf(AbstractHttpConfigurer::disable) - .authorizeHttpRequests( - customize -> - customize - .requestMatchers("/api/**") - .permitAll() - .requestMatchers(HttpMethod.OPTIONS, "/**") - .permitAll() - .anyRequest() - .permitAll()) - .httpBasic(AbstractHttpConfigurer::disable) - .formLogin(AbstractHttpConfigurer::disable); - - return http.build(); - } -} diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/security/UserAuthenticationHelper.java b/backend/src/main/java/ca/bc/gov/backendstartapi/security/UserAuthenticationHelper.java index 7c0762817..2ceecd632 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/security/UserAuthenticationHelper.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/security/UserAuthenticationHelper.java @@ -1,12 +1,8 @@ package ca.bc.gov.backendstartapi.security; import ca.bc.gov.backendstartapi.config.SparLog; -import java.util.Arrays; -import java.util.Objects; import java.util.Optional; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.oauth2.jwt.Jwt; @@ -17,8 +13,6 @@ @RequiredArgsConstructor public class UserAuthenticationHelper { - @Autowired private Environment environment; - /** * Get the logged user information. * @@ -90,18 +84,6 @@ public Optional getUserInfo() { SparLog.info("User not authenticated!"); - // Checks if it's the 'docker-compose' profile enabled (local dev env) - boolean isDockerComposeProfile = false; - if (!Objects.isNull(environment)) { - String[] profiles = environment.getActiveProfiles(); - isDockerComposeProfile = Arrays.asList(profiles).contains("docker-compose"); - } - - if (isDockerComposeProfile) { - SparLog.info("Local development environment found! Using dev user!"); - return Optional.of(UserInfo.createDevUser()); - } - return Optional.empty(); } } diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 34f689105..74d9817e5 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -8,8 +8,6 @@ server.error.include-message=always # Actuator and ops management.endpoint.health.show-details = always -spring.docker.compose.enabled = false -spring.docker.compose.file = docker-compose-dev.yml # Others nr-spar-backend-version = ${NR_SPAR_BACKEND_VERSION:local} diff --git a/backend/src/main/resources/docker-compose-dev.yml b/backend/src/main/resources/docker-compose-dev.yml deleted file mode 100644 index f6e6c73e3..000000000 --- a/backend/src/main/resources/docker-compose-dev.yml +++ /dev/null @@ -1,19 +0,0 @@ -version: '3.9' - -services: - database: - container_name: database - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: default - POSTGRES_DB: postgres - volumes: ["/pgdata"] - ports: ["5432:5432"] - healthcheck: - test: pg_isready -U postgres - interval: 5s - timeout: 5s - retries: 5 - image: postgis/postgis:13-master - labels: - org.springframework.boot.service-connection: postgres