Skip to content

Commit

Permalink
Merge pull request #9 from mash-up-kr/feature/jasypt
Browse files Browse the repository at this point in the history
feat: Apply jasypt hoho
  • Loading branch information
god9599 committed Jun 23, 2024
2 parents 129fcd7 + 41499c2 commit 5894272
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ plugins {

java.sourceCompatibility = JavaVersion.VERSION_21

val jasyptVersion: String by project.extra

allprojects {
group = "com.mashup.ppangzip"
version = "0.0.1-SNAPSHOT"
Expand All @@ -27,7 +29,9 @@ subprojects {
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("com.github.ulisesbocchio:jasypt-spring-boot-starter:${jasyptVersion}")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
jjwtVersion=0.11.5
mysqlConnectorVersion=8.0.33
springDocOpenApiVersion=2.0.2
jasyptVersion=3.0.5
6 changes: 3 additions & 3 deletions pic-api/src/main/resources/application-domain.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
spring:
datasource:
url: ${MYSQL_URL}
username: ${MYSQL_USERNAME}
password: ${MYSQL_PASSWORD}
url: ENC(Ay1RamiVb1M/bs+asVmYBsfpJKWCV/GlfYiAJTiO5nW7l9HAeGWVDneMntFvqS+myIfeypom11iMvX0KAXkBKnRd408MJWVuepy8uMU6tR+NqmwTJBOdSd9flGdOvSlnyG7l/YqwK46KtSC513pNwsV8UlIypgEDVn+Of3q/N2biF/oUXcJRsmGxn5XzY7v8InR+CBoakJJmCzHaaYPxMRQFEd/l3a9bsTfyNSUcbYg=)
username: ENC(MeGy+GMnB7qvepqgo1UWRTBadVuqO/NYMlQmif0WItNsbzShuX2U5Dl4iVKrznuz)
password: ENC(9hUR9OvMkz9IEOgjKsf7uXbUaLUaT1RXGR9AjOU2vDYEhVuTwFtu+vyU9IPv6HzHfmK16liLpmKXdBsf2OkZyg==)
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
hibernate:
Expand Down
6 changes: 3 additions & 3 deletions pic-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ spring:
import:
- classpath:/application-domain.yaml
jwt:
secret-key: ${SECRET_KEY}
secret-key: ENC(NtDCxHj5jr9w2VZJ8ePLbjYrgB5mcL68ysQhvGgnj53mqiHnML6eWOi3X0sL4CRUnvqZMEKx9af16oM02kKDj91w76d72ljnLVhT49M1lhc=)
kakao:
issuer: https://kauth.kakao.com
audience:
rest: ${KAKAO_REST_KEY}
native: ${KAKAO_NATIVE_KEY}
rest: ENC(fEnBOJApIyZToWk4lc77g7xYnG20FhdIFwAJkolwbrEWZ5S+Gm/gJWUbMFciWL99oSEVLhTJxUOzxZWjr4Z+8A==)
native: ENC(/vP+mCyAS0JwUoWO207Sp4OwXLiiYdF//59zusyXxoEB8MJg0q8AYVEzubY5EGdhM/rioCqlhAQyqDgZuwxws2pwdONcc1qG7SDksRymywQ=)
jwk-uri: https://kauth.kakao.com/.well-known/jwks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mashup.pic.config

import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties
import org.springframework.context.annotation.Configuration

@Configuration
@EnableEncryptableProperties
class JasyptConfig
8 changes: 8 additions & 0 deletions pic-common/src/test/kotlin/com/mashup/pic/SharedContext.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.mashup.pic

import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.TestConstructor

@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
abstract class SharedContext
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.mashup.pic.config

import com.mashup.pic.SharedContext
import org.hamcrest.Matchers.`is`
import org.hamcrest.MatcherAssert.assertThat
import org.jasypt.encryption.StringEncryptor
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest

/**
* Run > Edit Configurations > Configuration > Environment variables > 'JASYPT_ENCRYPTOR_PASSWORD={암호화키}' 입력
*/
@Disabled("암호화, 복호화 결과 확인을 위한 테스트이므로 비활성화")
@SpringBootTest(classes = [JasyptConfig::class])
class JasyptConfigTest(
private val stringEncryptor: StringEncryptor
) : SharedContext() {

private val plainText: String = "test"

@Test
fun execute() {
stringEncryptor.encrypt(plainText).let { encrypted ->
println(encrypted)
assertThat(stringEncryptor.decrypt(encrypted), `is`(plainText))
}
}
}

0 comments on commit 5894272

Please sign in to comment.