Skip to content

Commit 7233c48

Browse files
authored
Make OTP response optional and toggle via config (#657)
1 parent dd9bedf commit 7233c48

8 files changed

Lines changed: 15 additions & 8 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package co.nilin.opex.api.core.inout
22

3-
data class TempOtpResponse(val otp: String, var receivers: List<OTPReceiver>? = null)
3+
data class TempOtpResponse(val otp: String?, var receivers: List<OTPReceiver>? = null)

auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/model/OTP.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ data class OTPVerifyResponse(
2626
)
2727

2828
//TODO IMPORTANT: remove in production
29-
data class TempOtpResponse(val otp: String, val otpReceiver: OTPReceiver?)
29+
data class TempOtpResponse(val otp: String?, val otpReceiver: OTPReceiver?)
3030

3131
enum class OTPAction {
3232
REGISTER, FORGET, NONE

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ services:
545545
- SMTP_PASS=${SMTP_PASS}
546546
- SMTP_FROM=${SMTP_FROM}
547547
- TOKEN_ISSUER_URL=${KC_ISSUER_URL}
548+
- OTP_CODE_RESPONSE_ENABLED=${OTP_CODE_RESPONSE_ENABLED}
548549
depends_on:
549550
- consul
550551
- postgres-otp

otp/otp-app/src/main/kotlin/co/nilin/opex/otp/app/controller/OTPController.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import co.nilin.opex.otp.app.data.OTPResult
66
import co.nilin.opex.otp.app.data.VerifyOTPRequest
77
import co.nilin.opex.otp.app.model.OTPType
88
import co.nilin.opex.otp.app.service.OTPService
9+
import org.springframework.beans.factory.annotation.Value
910
import org.springframework.http.HttpStatus
1011
import org.springframework.http.ResponseEntity
1112
import org.springframework.web.bind.annotation.PostMapping
@@ -15,10 +16,13 @@ import org.springframework.web.bind.annotation.RestController
1516

1617
@RestController
1718
@RequestMapping("/v1/otp")
18-
class OTPController(private val otpService: OTPService) {
19+
class OTPController(
20+
private val otpService: OTPService,
21+
@Value("\${otp.response-enabled}") private val otpCodeResponseEnabled: Boolean,
22+
) {
1923

2024
//TODO IMPORTANT: remove in production
21-
data class TempOtpResponse(val otp: String)
25+
data class TempOtpResponse(val otp: String?)
2226
//TODO IMPORTANT: remove in production
2327

2428
//TODO IMPORTANT: remove in production
@@ -34,7 +38,8 @@ class OTPController(private val otpService: OTPService) {
3438
)
3539
else
3640
otpService.requestCompositeOTP(request.receivers.toSet(), request.userId, request.action)
37-
return ResponseEntity.status(HttpStatus.CREATED).body(TempOtpResponse(code))
41+
val tempOtpResponse = if (otpCodeResponseEnabled) code else null
42+
return ResponseEntity.status(HttpStatus.CREATED).body(TempOtpResponse(tempOtpResponse))
3843
}
3944

4045
@PostMapping("/verify")

otp/otp-app/src/main/resources/application.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ app:
4848
cert-url: http://keycloak:8080/realms/opex/protocol/openid-connect/certs
4949
iss-url: ${TOKEN_ISSUER_URL:http://keycloak:8080/realms/opex}
5050
otp:
51+
response-enabled: ${OTP_CODE_RESPONSE_ENABLED:false}
5152
sms:
5253
provider:
5354
url: ${SMS_PROVIDER_URL}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package co.nilin.opex.profile.core.data.otp
22

3-
data class TempOtpResponse(val otp: String, var otpReceiver: OTPReceiver?)
3+
data class TempOtpResponse(val otp: String?, var otpReceiver: OTPReceiver?)

wallet/wallet-app/src/main/kotlin/co/nilin/opex/wallet/app/service/WalletSnapshotService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class WalletSnapshotService(
2929
}
3030
}
3131

32-
@Scheduled(cron = "0 40 16 * * ?", zone = "GMT" + "\${app.zone-offset}")
32+
@Scheduled(cron = "0 0 0 * * ?", zone = "GMT" + "\${app.zone-offset}")
3333
fun createDetailAssetsSnapshot() {
3434
runBlocking {
3535
updatePrices()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package co.nilin.opex.wallet.core.inout.otp
22

3-
data class TempOtpResponse(val otp: String, var receivers: List<OTPReceiver>? = null)
3+
data class TempOtpResponse(val otp: String?, var receivers: List<OTPReceiver>? = null)

0 commit comments

Comments
 (0)