From 5697cab00dc90ee2bc5ac5e042ea5ecbc937597b Mon Sep 17 00:00:00 2001 From: Sewook Date: Sat, 21 Sep 2024 16:17:05 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20=EC=9D=98=EC=A1=B4=EC=84=B1=20?= =?UTF-8?q?=EB=B0=8F=20yml=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/port/out/smtp/SmtpPort.kt | 6 +++++ .../applicant-smtp-adapter/build.gradle.kts | 5 ++++ .../src/main/resources/application.yml | 13 +++++++++ .../src/main/resources/templates/stmp.html | 27 +++++++++++++++++++ settings.gradle.kts | 1 + 5 files changed, 52 insertions(+) create mode 100644 applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/smtp/SmtpPort.kt create mode 100644 applicant/applicant-smtp-adapter/build.gradle.kts create mode 100644 applicant/applicant-smtp-adapter/src/main/resources/application.yml create mode 100644 applicant/applicant-smtp-adapter/src/main/resources/templates/stmp.html diff --git a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/smtp/SmtpPort.kt b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/smtp/SmtpPort.kt new file mode 100644 index 00000000..845d018a --- /dev/null +++ b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/smtp/SmtpPort.kt @@ -0,0 +1,6 @@ +package com.daegusw.apply.applicant.application.port.out.smtp + +interface SmtpPort { + fun send(e: String) : String + fun verify(e: String) : String +} \ No newline at end of file diff --git a/applicant/applicant-smtp-adapter/build.gradle.kts b/applicant/applicant-smtp-adapter/build.gradle.kts new file mode 100644 index 00000000..68c22479 --- /dev/null +++ b/applicant/applicant-smtp-adapter/build.gradle.kts @@ -0,0 +1,5 @@ +dependencies { + implementation("org.springframework.boot:spring-boot-starter-thymeleaf") + implementation("aws.sdk.kotlin:ses:0.16.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") +} \ No newline at end of file diff --git a/applicant/applicant-smtp-adapter/src/main/resources/application.yml b/applicant/applicant-smtp-adapter/src/main/resources/application.yml new file mode 100644 index 00000000..f8599c88 --- /dev/null +++ b/applicant/applicant-smtp-adapter/src/main/resources/application.yml @@ -0,0 +1,13 @@ +spring: + thymeleaf: + prefix: classpath:/templates + suffix: .html + mode: HTML + encoding: UTF-8 + check-template-location: true + cache: false +cloud: + aws: + credentials: + access-key: ${aws.credentials.accessKey} + secret-key: ${aws.credentials.secretKey} \ No newline at end of file diff --git a/applicant/applicant-smtp-adapter/src/main/resources/templates/stmp.html b/applicant/applicant-smtp-adapter/src/main/resources/templates/stmp.html new file mode 100644 index 00000000..9b605bbe --- /dev/null +++ b/applicant/applicant-smtp-adapter/src/main/resources/templates/stmp.html @@ -0,0 +1,27 @@ + + + + + + + +
+

+ IDA 인증번호 안내입니다. +

+

+ 아래 인증번호5분내로 입력해주세요. +

+ +
+

+
+ +
+

+ 아무에게도 이 번호를 공유하지마세요. 회원 정보가 유출되는 문제가 발생 할 수 있습니다.
+

+
+
+ + \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index ab4970cb..fe3021b0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,6 +22,7 @@ include("applicant:applicant-domain") include("applicant:applicant-application") include("applicant:applicant-jpa-adapter") include("applicant:applicant-s3-adapter") +include("applicant:applicant-smtp-adapter") include("applicant:applicant-web-adapter") include("admission") From 9d994297d3bd592b21e82c7102f88b0a0cbb553b Mon Sep 17 00:00:00 2001 From: Sewook Date: Mon, 23 Sep 2024 13:49:14 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=9D=B8=EC=A6=9D=20=EC=BD=94=EB=93=9C=20api=20=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/port/in/web/SmtpUseCase.kt | 6 ++ .../application/port/out/redis/RedisPort.kt | 7 +++ .../application/port/out/smtp/SmtpPort.kt | 3 +- .../application/service/SmtpService.kt | 31 ++++++++++ .../applicant-redis-adapter/build.gradle.kts | 4 ++ .../applicant/redis/adapter/RedisAdapter.kt | 24 ++++++++ .../redis/adapter/common/RedisConfig.kt | 35 +++++++++++ .../src/main/resources/application.yml | 4 ++ .../applicant-smtp-adapter/build.gradle.kts | 2 + .../applicant/smtp/adapter/SmtpAdapter.kt | 59 +++++++++++++++++++ .../adapter/common/ApplicantStmpProperties.kt | 14 +++++ .../src/main/resources/application.yml | 4 +- .../applicant-web-adapter/build.gradle.kts | 1 + .../web/adapter/api/SmtpController.kt | 31 ++++++++++ .../web/adapter/api/request/SmtpRequest.kt | 11 ++++ settings.gradle.kts | 1 + 16 files changed, 234 insertions(+), 3 deletions(-) create mode 100644 applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/in/web/SmtpUseCase.kt create mode 100644 applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/redis/RedisPort.kt create mode 100644 applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt create mode 100644 applicant/applicant-redis-adapter/build.gradle.kts create mode 100644 applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt create mode 100644 applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt create mode 100644 applicant/applicant-redis-adapter/src/main/resources/application.yml create mode 100644 applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/SmtpAdapter.kt create mode 100644 applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantStmpProperties.kt create mode 100644 applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt create mode 100644 applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/request/SmtpRequest.kt diff --git a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/in/web/SmtpUseCase.kt b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/in/web/SmtpUseCase.kt new file mode 100644 index 00000000..769f54f5 --- /dev/null +++ b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/in/web/SmtpUseCase.kt @@ -0,0 +1,6 @@ +package com.daegusw.apply.applicant.application.port.`in`.web + +interface SmtpUseCase { + suspend fun verify(email: String, code: String): String + suspend fun send(email: String): String +} \ No newline at end of file diff --git a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/redis/RedisPort.kt b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/redis/RedisPort.kt new file mode 100644 index 00000000..d7f89aaf --- /dev/null +++ b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/redis/RedisPort.kt @@ -0,0 +1,7 @@ +package com.daegusw.apply.applicant.application.port.out.redis + +interface RedisPort { + fun save(key: String, value: String, expiration: Long) + fun delete(key: String) + fun get(key: String): String? +} \ No newline at end of file diff --git a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/smtp/SmtpPort.kt b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/smtp/SmtpPort.kt index 845d018a..30a76d7c 100644 --- a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/smtp/SmtpPort.kt +++ b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/smtp/SmtpPort.kt @@ -1,6 +1,5 @@ package com.daegusw.apply.applicant.application.port.out.smtp interface SmtpPort { - fun send(e: String) : String - fun verify(e: String) : String + suspend fun send(e: String) : String } \ No newline at end of file diff --git a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt new file mode 100644 index 00000000..fbdc9d2d --- /dev/null +++ b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt @@ -0,0 +1,31 @@ +package com.daegusw.apply.applicant.application.service + +import com.daegusw.apply.applicant.application.port.`in`.web.SmtpUseCase +import com.daegusw.apply.applicant.application.port.out.redis.RedisPort +import com.daegusw.apply.applicant.application.port.out.smtp.SmtpPort +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional + +@Service +class SmtpService( + private val stmpPort: SmtpPort, + private val redisPort: RedisPort, +) : SmtpUseCase { + + @Transactional(rollbackFor = [Exception::class]) + override suspend fun verify(email: String, code: String): String { + val value = redisPort.get(email) + if((value != null) && value == code){ + return "verified" + } + throw RuntimeException("Smtp verification failed") + } + + @Transactional(rollbackFor = [Exception::class]) + override suspend fun send(email: String): String { + val code = stmpPort.send(email) + redisPort.save(email,code,3L) //3분 + return "smtp success" + } + +} \ No newline at end of file diff --git a/applicant/applicant-redis-adapter/build.gradle.kts b/applicant/applicant-redis-adapter/build.gradle.kts new file mode 100644 index 00000000..387b9ed8 --- /dev/null +++ b/applicant/applicant-redis-adapter/build.gradle.kts @@ -0,0 +1,4 @@ +dependencies { + implementation("org.springframework.boot:spring-boot-starter-data-redis") + implementation(project(":applicant:applicant-application")) +} \ No newline at end of file diff --git a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt new file mode 100644 index 00000000..496e3da5 --- /dev/null +++ b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt @@ -0,0 +1,24 @@ +package com.daegusw.apply.applicant.redis.adapter + +import com.daegusw.apply.applicant.application.port.out.redis.RedisPort +import org.springframework.data.redis.core.RedisTemplate +import org.springframework.stereotype.Component +import java.time.Duration + +@Component +class RedisAdapter( + private val redisTemplate: RedisTemplate, +) : RedisPort { + override fun save(key: String, value: String, expiration: Long) { + redisTemplate.opsForValue().set(key, value, Duration.ofMinutes(expiration)) + } + + override fun delete(key: String) { + redisTemplate.delete(key) + } + + override fun get(key: String): String? { + return redisTemplate.opsForValue().get(key) + } + +} \ No newline at end of file diff --git a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt new file mode 100644 index 00000000..84c8ae1a --- /dev/null +++ b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt @@ -0,0 +1,35 @@ +package com.daegusw.apply.applicant.redis.adapter.common + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.data.redis.connection.RedisConnectionFactory +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory +import org.springframework.data.redis.core.RedisTemplate +import org.springframework.data.redis.serializer.StringRedisSerializer + +@Configuration +class RedisConfig( + @Value("\${spring.redis.host}") + val host: String, + + @Value("\${spring.redis.port}") + val port: Int, +) { + + @Bean + fun redisConnectionFactory(): RedisConnectionFactory { + return LettuceConnectionFactory(host, port) + } + + @Bean + fun redisTemplate(): RedisTemplate<*, *> { + return RedisTemplate().apply { + this.setConnectionFactory(redisConnectionFactory()) +// 불편한 값 삭제 + this.keySerializer = StringRedisSerializer() + this.hashKeySerializer = StringRedisSerializer() + this.valueSerializer = StringRedisSerializer() + } + } +} \ No newline at end of file diff --git a/applicant/applicant-redis-adapter/src/main/resources/application.yml b/applicant/applicant-redis-adapter/src/main/resources/application.yml new file mode 100644 index 00000000..351b1642 --- /dev/null +++ b/applicant/applicant-redis-adapter/src/main/resources/application.yml @@ -0,0 +1,4 @@ +spring: + redis: + host: localhost + port: 6379 \ No newline at end of file diff --git a/applicant/applicant-smtp-adapter/build.gradle.kts b/applicant/applicant-smtp-adapter/build.gradle.kts index 68c22479..f0e0cc11 100644 --- a/applicant/applicant-smtp-adapter/build.gradle.kts +++ b/applicant/applicant-smtp-adapter/build.gradle.kts @@ -2,4 +2,6 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-thymeleaf") implementation("aws.sdk.kotlin:ses:0.16.0") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") + implementation ("org.springframework.boot:spring-boot-starter-mail") + implementation(project(":applicant:applicant-application")) } \ No newline at end of file diff --git a/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/SmtpAdapter.kt b/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/SmtpAdapter.kt new file mode 100644 index 00000000..4101e64d --- /dev/null +++ b/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/SmtpAdapter.kt @@ -0,0 +1,59 @@ +package com.daegusw.apply.applicant.smtp.adapter + +import aws.sdk.kotlin.runtime.auth.credentials.StaticCredentialsProvider +import aws.sdk.kotlin.services.ses.SesClient +import aws.sdk.kotlin.services.ses.model.* +import com.daegusw.apply.applicant.application.port.out.smtp.SmtpPort +import com.daegusw.apply.applicant.smtp.adapter.common.ApplicantStmpProperties +import org.springframework.stereotype.Component +import org.thymeleaf.context.Context +import org.thymeleaf.spring5.SpringTemplateEngine + +@Component +class SmtpAdapter( + private val applicantStmpProperties: ApplicantStmpProperties, + private val templateEngine: SpringTemplateEngine, + ) : SmtpPort { + override suspend fun send(e: String) : String { + try{ + val code = (1..5).map { (0..9).random() }.joinToString("") + val context = Context() + context.setVariable("code", code) + + val emailRequest = SendEmailRequest { + destination = Destination { + toAddresses = listOf(e) + } + + message = Message { + subject = Content { + data = "인증 번호" + } + + body = Body { + html = Content { + data = templateEngine.process("code", context) + } + } + } + + source = applicantStmpProperties.sendEmail + } + + SesClient { + region = applicantStmpProperties.region + + credentialsProvider = StaticCredentialsProvider { + accessKeyId = applicantStmpProperties.accessKey + secretAccessKey = applicantStmpProperties.secretKey + } + }.use { + it.sendEmail(emailRequest) + } + return code + }catch (e:Exception){ + throw RuntimeException() + } + } + +} \ No newline at end of file diff --git a/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantStmpProperties.kt b/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantStmpProperties.kt new file mode 100644 index 00000000..c9ccd631 --- /dev/null +++ b/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantStmpProperties.kt @@ -0,0 +1,14 @@ +package com.daegusw.apply.applicant.smtp.adapter.common + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.PropertySource +import org.springframework.stereotype.Component + +@Component +@PropertySource("classpath:application.yml") +class ApplicantStmpProperties ( + @Value("\${cloud.aws.credentials.access-key:access-key}") val accessKey : String, + @Value("\${cloud.aws.credentials.secret-key:secret-key}") val secretKey : String, + @Value("\${cloud.aws.region}") val region : String, + @Value("\${cloud.aws.credentials.send-mail-to}") val sendEmail : String, +) \ No newline at end of file diff --git a/applicant/applicant-smtp-adapter/src/main/resources/application.yml b/applicant/applicant-smtp-adapter/src/main/resources/application.yml index f8599c88..59f5fbd2 100644 --- a/applicant/applicant-smtp-adapter/src/main/resources/application.yml +++ b/applicant/applicant-smtp-adapter/src/main/resources/application.yml @@ -10,4 +10,6 @@ cloud: aws: credentials: access-key: ${aws.credentials.accessKey} - secret-key: ${aws.credentials.secretKey} \ No newline at end of file + secret-key: ${aws.credentials.secretKey} + send-mail-to: dgswcns@gmail.com + region: ap-northeast-2 \ No newline at end of file diff --git a/applicant/applicant-web-adapter/build.gradle.kts b/applicant/applicant-web-adapter/build.gradle.kts index c34fb399..67289bee 100644 --- a/applicant/applicant-web-adapter/build.gradle.kts +++ b/applicant/applicant-web-adapter/build.gradle.kts @@ -9,4 +9,5 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-validation") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") } \ No newline at end of file diff --git a/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt new file mode 100644 index 00000000..f5d6c6fa --- /dev/null +++ b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt @@ -0,0 +1,31 @@ +package com.daegusw.apply.applicant.web.adapter.api + +import com.daegusw.apply.applicant.application.port.`in`.web.SmtpUseCase +import com.daegusw.apply.applicant.web.adapter.api.request.SmtpRequest +import kotlinx.coroutines.runBlocking +import org.springframework.http.HttpStatus +import org.springframework.web.bind.annotation.* + +@RestController +@RequestMapping("/applicant/stmp") +class SmtpController( + private val smtpUseCase: SmtpUseCase +) { + @ResponseStatus(HttpStatus.OK) + @GetMapping + fun send(@RequestParam email: String) : String { + return runBlocking { + smtpUseCase.send(email) + "전송 완료" + } + } + + @ResponseStatus(HttpStatus.OK) + @PostMapping + fun verify(@RequestBody smtpRequest: SmtpRequest) : String{ + return runBlocking { + smtpUseCase.verify(smtpRequest.email,smtpRequest.code) + } + } + +} \ No newline at end of file diff --git a/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/request/SmtpRequest.kt b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/request/SmtpRequest.kt new file mode 100644 index 00000000..a4fb1481 --- /dev/null +++ b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/request/SmtpRequest.kt @@ -0,0 +1,11 @@ +package com.daegusw.apply.applicant.web.adapter.api.request + +import javax.validation.constraints.Email +import javax.validation.constraints.NotEmpty + +data class SmtpRequest( + @field:Email(message = "email is required") + val email: String, + @field:NotEmpty(message = "code is required") + val code: String, +) diff --git a/settings.gradle.kts b/settings.gradle.kts index fe3021b0..28344891 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,6 +24,7 @@ include("applicant:applicant-jpa-adapter") include("applicant:applicant-s3-adapter") include("applicant:applicant-smtp-adapter") include("applicant:applicant-web-adapter") +include("applicant:applicant-redis-adapter") include("admission") include("admission:admission-domain") From 2ae662e75b7abf9d46564b8d79fa9ad99afcab95 Mon Sep 17 00:00:00 2001 From: Sewook Date: Mon, 23 Sep 2024 19:15:38 +0900 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=80=EC=9E=A5=20api=20=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/build.gradle.kts | 2 ++ .../src/main/resources/templates/stmp.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/build.gradle.kts b/api/build.gradle.kts index f25fbc7c..4503682a 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -9,6 +9,8 @@ dependencies { implementation(project(":applicant:applicant-jpa-adapter")) implementation(project(":applicant:applicant-web-adapter")) implementation(project(":applicant:applicant-s3-adapter")) + implementation(project(":applicant:applicant-redis-adapter")) + implementation(project(":applicant:applicant-smtp-adapter")) implementation(project(":admission:admission-application")) implementation(project(":admission:admission-jpa-adapter")) diff --git a/applicant/applicant-smtp-adapter/src/main/resources/templates/stmp.html b/applicant/applicant-smtp-adapter/src/main/resources/templates/stmp.html index 9b605bbe..6f201903 100644 --- a/applicant/applicant-smtp-adapter/src/main/resources/templates/stmp.html +++ b/applicant/applicant-smtp-adapter/src/main/resources/templates/stmp.html @@ -10,7 +10,7 @@

IDA 인증번호 안내입니다.

- 아래 인증번호5분내로 입력해주세요. + 아래 인증번호3분내로 입력해주세요.

From a275e201767c0053413bbfa6cd5d32dcced10b31 Mon Sep 17 00:00:00 2001 From: Sewook Date: Mon, 23 Sep 2024 20:26:50 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .kotlin/errors/errors-1727090346428.log | 4 ++++ .../application/service/SmtpService.kt | 3 --- .../applicant/redis/adapter/RedisAdapter.kt | 19 ++++++++++++++++--- .../redis/adapter/common/RedisConfig.kt | 3 +++ .../web/adapter/api/SmtpController.kt | 16 +++++++++++----- .../web/adapter/api/response/SmtpResponse.kt | 5 +++++ 6 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 .kotlin/errors/errors-1727090346428.log create mode 100644 applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/response/SmtpResponse.kt diff --git a/.kotlin/errors/errors-1727090346428.log b/.kotlin/errors/errors-1727090346428.log new file mode 100644 index 00000000..7cd151b6 --- /dev/null +++ b/.kotlin/errors/errors-1727090346428.log @@ -0,0 +1,4 @@ +kotlin version: 2.0.20 +error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output: + 1. Kotlin compile daemon is ready + diff --git a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt index fbdc9d2d..a8ecaa63 100644 --- a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt +++ b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt @@ -4,7 +4,6 @@ import com.daegusw.apply.applicant.application.port.`in`.web.SmtpUseCase import com.daegusw.apply.applicant.application.port.out.redis.RedisPort import com.daegusw.apply.applicant.application.port.out.smtp.SmtpPort import org.springframework.stereotype.Service -import org.springframework.transaction.annotation.Transactional @Service class SmtpService( @@ -12,7 +11,6 @@ class SmtpService( private val redisPort: RedisPort, ) : SmtpUseCase { - @Transactional(rollbackFor = [Exception::class]) override suspend fun verify(email: String, code: String): String { val value = redisPort.get(email) if((value != null) && value == code){ @@ -21,7 +19,6 @@ class SmtpService( throw RuntimeException("Smtp verification failed") } - @Transactional(rollbackFor = [Exception::class]) override suspend fun send(email: String): String { val code = stmpPort.send(email) redisPort.save(email,code,3L) //3분 diff --git a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt index 496e3da5..fa2fce25 100644 --- a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt +++ b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt @@ -10,15 +10,28 @@ class RedisAdapter( private val redisTemplate: RedisTemplate, ) : RedisPort { override fun save(key: String, value: String, expiration: Long) { - redisTemplate.opsForValue().set(key, value, Duration.ofMinutes(expiration)) + try{ + redisTemplate.opsForValue().set(key, value, Duration.ofMinutes(expiration)) + + }catch(e:Exception){ + throw e + } } override fun delete(key: String) { - redisTemplate.delete(key) + try{ + redisTemplate.delete(key) + }catch(e:Exception){ + throw e + } } override fun get(key: String): String? { - return redisTemplate.opsForValue().get(key) + try { + return redisTemplate.opsForValue().get(key) + }catch(e:Exception){ + throw e + } } } \ No newline at end of file diff --git a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt index 84c8ae1a..762d9eed 100644 --- a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt +++ b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt @@ -7,6 +7,9 @@ import org.springframework.data.redis.connection.RedisConnectionFactory import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory import org.springframework.data.redis.core.RedisTemplate import org.springframework.data.redis.serializer.StringRedisSerializer +import org.springframework.transaction.PlatformTransactionManager +import org.springframework.transaction.TransactionManager + @Configuration class RedisConfig( diff --git a/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt index f5d6c6fa..fc577201 100644 --- a/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt +++ b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt @@ -2,9 +2,12 @@ package com.daegusw.apply.applicant.web.adapter.api import com.daegusw.apply.applicant.application.port.`in`.web.SmtpUseCase import com.daegusw.apply.applicant.web.adapter.api.request.SmtpRequest +import com.daegusw.apply.applicant.web.adapter.api.response.SmtpResponse import kotlinx.coroutines.runBlocking import org.springframework.http.HttpStatus import org.springframework.web.bind.annotation.* +import javax.validation.Valid +import javax.validation.constraints.NotEmpty @RestController @RequestMapping("/applicant/stmp") @@ -13,18 +16,21 @@ class SmtpController( ) { @ResponseStatus(HttpStatus.OK) @GetMapping - fun send(@RequestParam email: String) : String { + fun send(@NotEmpty(message = "email is required")@RequestParam email: String) : SmtpResponse { return runBlocking { - smtpUseCase.send(email) - "전송 완료" + SmtpResponse( + smtpUseCase.send(email) + "로 전송 완료" + ) } } @ResponseStatus(HttpStatus.OK) @PostMapping - fun verify(@RequestBody smtpRequest: SmtpRequest) : String{ + fun verify(@Valid @RequestBody smtpRequest: SmtpRequest) : SmtpResponse { return runBlocking { - smtpUseCase.verify(smtpRequest.email,smtpRequest.code) + SmtpResponse( + smtpUseCase.verify(smtpRequest.email,smtpRequest.code) + ) } } diff --git a/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/response/SmtpResponse.kt b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/response/SmtpResponse.kt new file mode 100644 index 00000000..c7066382 --- /dev/null +++ b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/response/SmtpResponse.kt @@ -0,0 +1,5 @@ +package com.daegusw.apply.applicant.web.adapter.api.response + +data class SmtpResponse( + val message : String, +) From 8faf29514c7d93d989c9a308cab32cc14d093e0d Mon Sep 17 00:00:00 2001 From: Sewook Date: Tue, 24 Sep 2024 09:55:42 +0900 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=8B=9C=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=20=ED=99=95=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/port/out/redis/RedisPort.kt | 1 + .../application/service/SmtpService.kt | 1 + .../applicant/redis/adapter/RedisAdapter.kt | 8 ++++++ .../service/SignupApplicantService.kt | 26 ++++++++++++------- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/redis/RedisPort.kt b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/redis/RedisPort.kt index d7f89aaf..75f6c344 100644 --- a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/redis/RedisPort.kt +++ b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/port/out/redis/RedisPort.kt @@ -4,4 +4,5 @@ interface RedisPort { fun save(key: String, value: String, expiration: Long) fun delete(key: String) fun get(key: String): String? + fun update(key: String, value: String) } \ No newline at end of file diff --git a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt index a8ecaa63..918a1712 100644 --- a/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt +++ b/applicant/applicant-application/src/main/kotlin/com/daegusw/apply/applicant/application/service/SmtpService.kt @@ -14,6 +14,7 @@ class SmtpService( override suspend fun verify(email: String, code: String): String { val value = redisPort.get(email) if((value != null) && value == code){ + redisPort.update(email, "verified") return "verified" } throw RuntimeException("Smtp verification failed") diff --git a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt index fa2fce25..a4f2ae67 100644 --- a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt +++ b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/RedisAdapter.kt @@ -34,4 +34,12 @@ class RedisAdapter( } } + override fun update(key: String, value: String) { + try{ + redisTemplate.opsForValue().set(key, value) + }catch(e:Exception){ + throw e + } + } + } \ No newline at end of file diff --git a/member/member-application/src/main/kotlin/com/daegusw/apply/memnber/application/service/SignupApplicantService.kt b/member/member-application/src/main/kotlin/com/daegusw/apply/memnber/application/service/SignupApplicantService.kt index 78cb84d4..556debd6 100644 --- a/member/member-application/src/main/kotlin/com/daegusw/apply/memnber/application/service/SignupApplicantService.kt +++ b/member/member-application/src/main/kotlin/com/daegusw/apply/memnber/application/service/SignupApplicantService.kt @@ -1,6 +1,7 @@ package com.daegusw.apply.memnber.application.service import com.daegusw.apply.applicant.application.port.out.persistence.CommandApplicantPort +import com.daegusw.apply.applicant.application.port.out.redis.RedisPort import com.daegusw.apply.applicant.domain.applicant.Applicant import com.daegusw.apply.core.hash.Sha512Encoder import com.daegusw.apply.core.idgen.IdGenerator @@ -20,20 +21,25 @@ class SignupApplicantService( private val queryMemberPort: QueryMemberPort, private val commandMemberPort: CommandMemberPort, private val commandApplicantPort: CommandApplicantPort, - private val sha512Encoder: Sha512Encoder + private val sha512Encoder: Sha512Encoder, + private val redisPort: RedisPort ) : SignupApplicantUseCase { override fun signupApplicant(memberCommand: MemberCommand) { if (queryMemberPort.existsByEmail(memberCommand.email)) { throw DuplicateEmailException(memberCommand.email) } - - commandMemberPort.saveMember( - Member( - id = MemberId(IdGenerator.generateUUIDWithLong()), - email = memberCommand.email, - password = Password(sha512Encoder.encode(memberCommand.password)), - role = Role.ROLE_APPLICANT - ) - ).also { commandApplicantPort.save(Applicant(it.id)) } + if (redisPort.get(memberCommand.email) == "verified"){ + commandMemberPort.saveMember( + Member( + id = MemberId(IdGenerator.generateUUIDWithLong()), + email = memberCommand.email, + password = Password(sha512Encoder.encode(memberCommand.password)), + role = Role.ROLE_APPLICANT + ) + ).also { commandApplicantPort.save(Applicant(it.id)) } + } + else{ + throw RuntimeException("Unauthorized Email") + } } } \ No newline at end of file From 1b6dcf0d8a5e1bec8a05f0638a6dfe295c5aabd6 Mon Sep 17 00:00:00 2001 From: Sewook Date: Tue, 24 Sep 2024 11:30:37 +0900 Subject: [PATCH 6/7] remove: remove runblocking --- .../applicant/web/adapter/api/SmtpController.kt | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt index fc577201..366f8951 100644 --- a/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt +++ b/applicant/applicant-web-adapter/src/main/kotlin/com/daegusw/apply/applicant/web/adapter/api/SmtpController.kt @@ -3,7 +3,6 @@ package com.daegusw.apply.applicant.web.adapter.api import com.daegusw.apply.applicant.application.port.`in`.web.SmtpUseCase import com.daegusw.apply.applicant.web.adapter.api.request.SmtpRequest import com.daegusw.apply.applicant.web.adapter.api.response.SmtpResponse -import kotlinx.coroutines.runBlocking import org.springframework.http.HttpStatus import org.springframework.web.bind.annotation.* import javax.validation.Valid @@ -16,22 +15,14 @@ class SmtpController( ) { @ResponseStatus(HttpStatus.OK) @GetMapping - fun send(@NotEmpty(message = "email is required")@RequestParam email: String) : SmtpResponse { - return runBlocking { - SmtpResponse( - smtpUseCase.send(email) + "로 전송 완료" - ) - } + suspend fun send(@NotEmpty(message = "email is required")@RequestParam email: String) : SmtpResponse { + return SmtpResponse(smtpUseCase.send(email) + "로 전송 완료") } @ResponseStatus(HttpStatus.OK) @PostMapping - fun verify(@Valid @RequestBody smtpRequest: SmtpRequest) : SmtpResponse { - return runBlocking { - SmtpResponse( - smtpUseCase.verify(smtpRequest.email,smtpRequest.code) - ) - } + suspend fun verify(@Valid @RequestBody smtpRequest: SmtpRequest) : SmtpResponse { + return SmtpResponse(smtpUseCase.verify(smtpRequest.email,smtpRequest.code)) } } \ No newline at end of file From 2020af15cfde9281ca9eeb10abafd753351bade0 Mon Sep 17 00:00:00 2001 From: Sewook Date: Tue, 24 Sep 2024 15:49:11 +0900 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20redis=20=EB=B0=8F=20ses=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=84=A4=EC=A0=95=20=EC=9D=B4=EC=8A=88=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../redis/adapter/common/RedisConfig.kt | 18 +++++------------- .../redis/adapter/common/RedisProperties.kt | 12 ++++++++++++ .../src/main/resources/application.yml | 2 +- .../applicant/smtp/adapter/SmtpAdapter.kt | 12 ++++++------ ...roperties.kt => ApplicantSmtpProperties.kt} | 6 +++--- .../src/main/resources/application.yml | 16 ++++++++-------- 6 files changed, 35 insertions(+), 31 deletions(-) create mode 100644 applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisProperties.kt rename applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/{ApplicantStmpProperties.kt => ApplicantSmtpProperties.kt} (70%) diff --git a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt index 762d9eed..a0666d8f 100644 --- a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt +++ b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisConfig.kt @@ -1,35 +1,27 @@ package com.daegusw.apply.applicant.redis.adapter.common -import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.data.redis.connection.RedisConnectionFactory import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory import org.springframework.data.redis.core.RedisTemplate +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories import org.springframework.data.redis.serializer.StringRedisSerializer -import org.springframework.transaction.PlatformTransactionManager -import org.springframework.transaction.TransactionManager - @Configuration +@EnableRedisRepositories class RedisConfig( - @Value("\${spring.redis.host}") - val host: String, - - @Value("\${spring.redis.port}") - val port: Int, + private val redisProperties: RedisProperties, ) { - @Bean fun redisConnectionFactory(): RedisConnectionFactory { - return LettuceConnectionFactory(host, port) + return LettuceConnectionFactory(redisProperties.host, redisProperties.port) } @Bean fun redisTemplate(): RedisTemplate<*, *> { return RedisTemplate().apply { - this.setConnectionFactory(redisConnectionFactory()) -// 불편한 값 삭제 + this.connectionFactory = redisConnectionFactory() this.keySerializer = StringRedisSerializer() this.hashKeySerializer = StringRedisSerializer() this.valueSerializer = StringRedisSerializer() diff --git a/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisProperties.kt b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisProperties.kt new file mode 100644 index 00000000..04131dc8 --- /dev/null +++ b/applicant/applicant-redis-adapter/src/main/kotlin/com/daegusw/apply/applicant/redis/adapter/common/RedisProperties.kt @@ -0,0 +1,12 @@ +package com.daegusw.apply.applicant.redis.adapter.common + +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.PropertySource +import org.springframework.stereotype.Component + +@Component +@PropertySource("classpath:application.yml") +class RedisProperties ( + @Value("\${spring.redis.host:host}") val host: String, + @Value("\${spring.redis.port:6379}") val port: Int, +) \ No newline at end of file diff --git a/applicant/applicant-redis-adapter/src/main/resources/application.yml b/applicant/applicant-redis-adapter/src/main/resources/application.yml index 351b1642..899a47e5 100644 --- a/applicant/applicant-redis-adapter/src/main/resources/application.yml +++ b/applicant/applicant-redis-adapter/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: redis: - host: localhost + host: ${redis.host} port: 6379 \ No newline at end of file diff --git a/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/SmtpAdapter.kt b/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/SmtpAdapter.kt index 4101e64d..3264145d 100644 --- a/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/SmtpAdapter.kt +++ b/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/SmtpAdapter.kt @@ -4,14 +4,14 @@ import aws.sdk.kotlin.runtime.auth.credentials.StaticCredentialsProvider import aws.sdk.kotlin.services.ses.SesClient import aws.sdk.kotlin.services.ses.model.* import com.daegusw.apply.applicant.application.port.out.smtp.SmtpPort -import com.daegusw.apply.applicant.smtp.adapter.common.ApplicantStmpProperties +import com.daegusw.apply.applicant.smtp.adapter.common.ApplicantSmtpProperties import org.springframework.stereotype.Component import org.thymeleaf.context.Context import org.thymeleaf.spring5.SpringTemplateEngine @Component class SmtpAdapter( - private val applicantStmpProperties: ApplicantStmpProperties, + private val applicantSmtpProperties: ApplicantSmtpProperties, private val templateEngine: SpringTemplateEngine, ) : SmtpPort { override suspend fun send(e: String) : String { @@ -37,15 +37,15 @@ class SmtpAdapter( } } - source = applicantStmpProperties.sendEmail + source = applicantSmtpProperties.sendEmailTo } SesClient { - region = applicantStmpProperties.region + region = applicantSmtpProperties.region credentialsProvider = StaticCredentialsProvider { - accessKeyId = applicantStmpProperties.accessKey - secretAccessKey = applicantStmpProperties.secretKey + accessKeyId = applicantSmtpProperties.accessKey + secretAccessKey = applicantSmtpProperties.secretKey } }.use { it.sendEmail(emailRequest) diff --git a/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantStmpProperties.kt b/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantSmtpProperties.kt similarity index 70% rename from applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantStmpProperties.kt rename to applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantSmtpProperties.kt index c9ccd631..0350f7a3 100644 --- a/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantStmpProperties.kt +++ b/applicant/applicant-smtp-adapter/src/main/kotlin/com/daegusw/apply/applicant/smtp/adapter/common/ApplicantSmtpProperties.kt @@ -6,9 +6,9 @@ import org.springframework.stereotype.Component @Component @PropertySource("classpath:application.yml") -class ApplicantStmpProperties ( +class ApplicantSmtpProperties ( @Value("\${cloud.aws.credentials.access-key:access-key}") val accessKey : String, @Value("\${cloud.aws.credentials.secret-key:secret-key}") val secretKey : String, - @Value("\${cloud.aws.region}") val region : String, - @Value("\${cloud.aws.credentials.send-mail-to}") val sendEmail : String, + @Value("\${cloud.aws.credentials.send-mail-to:send-mail-to}") val sendEmailTo : String, + @Value("\${cloud.aws.region:region}") val region : String, ) \ No newline at end of file diff --git a/applicant/applicant-smtp-adapter/src/main/resources/application.yml b/applicant/applicant-smtp-adapter/src/main/resources/application.yml index 59f5fbd2..0af2caac 100644 --- a/applicant/applicant-smtp-adapter/src/main/resources/application.yml +++ b/applicant/applicant-smtp-adapter/src/main/resources/application.yml @@ -1,3 +1,10 @@ +cloud: + aws: + credentials: + access-key: ${aws.credentials.accessKey} + secret-key: ${aws.credentials.secretKey} + send-mail-to: ${aws.credentials.sendMail} + region: ${aws.region} spring: thymeleaf: prefix: classpath:/templates @@ -5,11 +12,4 @@ spring: mode: HTML encoding: UTF-8 check-template-location: true - cache: false -cloud: - aws: - credentials: - access-key: ${aws.credentials.accessKey} - secret-key: ${aws.credentials.secretKey} - send-mail-to: dgswcns@gmail.com - region: ap-northeast-2 \ No newline at end of file + cache: false \ No newline at end of file