diff --git a/.github/workflows/pull-request-intergration.yml b/.github/workflows/pull-request-intergration.yml index 96c7fcccb..bc7135ba3 100644 --- a/.github/workflows/pull-request-intergration.yml +++ b/.github/workflows/pull-request-intergration.yml @@ -22,9 +22,8 @@ permissions: pull-requests: write jobs: - build: - runs-on: ubuntu-latest # 실행 환경 지정 - + setup: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up JDK 17 @@ -33,6 +32,11 @@ jobs: java-version: '17' distribution: 'temurin' + cache-dependencies: + needs: setup + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - name: Caching Dependencies uses: actions/cache@v3 with: @@ -42,22 +46,33 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle- - - + + build: + needs: cache-dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Build with Gradle run: ./gradlew build -x test + test: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 - name: Test with Gradle run: ./gradlew test + report: + needs: test + runs-on: ubuntu-latest + steps: - name: Setup Python uses: actions/setup-python@v4 with: python-version: 3.8 - - name: Report Test Results uses: EnricoMi/publish-unit-test-result-action@v2 if: ${{ always() }} diff --git a/.gitignore b/.gitignore index ce5b2161f..daec9abe0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ build/ !**/src/test/**/build/ ### Config ### -.yml +src/main/resources/application-prod.yml ### STS ### .apt_generated diff --git a/build.gradle b/build.gradle index e4f1f8853..dd9218e25 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta' + implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'com.h2database:h2' diff --git a/src/main/java/org/kakaoshare/backend/common/config/JasyptConfig.java b/src/main/java/org/kakaoshare/backend/common/config/JasyptConfig.java new file mode 100644 index 000000000..88a77187f --- /dev/null +++ b/src/main/java/org/kakaoshare/backend/common/config/JasyptConfig.java @@ -0,0 +1,35 @@ +package org.kakaoshare.backend.common.config; + +import org.jasypt.encryption.StringEncryptor; +import org.jasypt.encryption.pbe.PooledPBEStringEncryptor; +import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class JasyptConfig { + + public static final String PBE_WITH_MD_5_AND_DES = "PBEWithMD5AndDES"; + public static final String BASE_64 = "base64"; + public static final String ITERATIONS = "1000"; + public static final String RANDOM_SALT_GENERATOR = "org.jasypt.salt.RandomSaltGenerator"; + public static final String POOL_SIZE = "1"; + + @Value("${jasypt.encryptor.password}") + private String encryptKey; + + @Bean("jasyptStringEncryptor") + public StringEncryptor stringEncryptor(){ + PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor(); + SimpleStringPBEConfig config = new SimpleStringPBEConfig(); + config.setPassword(encryptKey); + config.setPoolSize(POOL_SIZE); + config.setAlgorithm(PBE_WITH_MD_5_AND_DES); + config.setStringOutputType(BASE_64); + config.setKeyObtentionIterations(ITERATIONS); + config.setSaltGeneratorClassName(RANDOM_SALT_GENERATOR); + encryptor.setConfig(config); + return encryptor; + } +} \ No newline at end of file diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 04ffd5fd1..82e84c942 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -10,6 +10,6 @@ spring: hibernate: ddl-auto: create datasource: - username: sa + username: ENC(2SkZyC/z/C0Um0i4IOtuAA==) password: driver-class-name: org.h2.Driver \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b1378917..000000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c82d028a3..12d0835bd 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -4,3 +4,4 @@ spring: # active: prod active: dev # active: test + include: secret \ No newline at end of file