Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/api-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ app:
url: http://opex-bc-gateway
auth:
cert-url: http://keycloak:8080/realms/opex/protocol/openid-connect/certs
iss-url: http://keycloak:8080/realms/opex
iss-url: ${TOKEN_ISSUER_URL:http://keycloak:8080}/realms/opex
token-url: http://keycloak:8080/realms/opex/protocol/openid-connect/token
api-key-client:
secret: ${API_KEY_CLIENT_SECRET}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ data class ConfirmPasswordFlowTokenRequest(
val rememberMe: Boolean = true,
): Device()

data class ResendOtpRequest(
val username: String,
val token: String,
val clientId: String
)


data class RefreshTokenRequest(
val clientId: String,
val clientSecret: String?,
Expand Down Expand Up @@ -72,4 +79,10 @@ data class TokenResponse(
data class RequiredOTP(
val type: OTPType,
val receiver: String?
)

data class ResendOtpResponse(
val otp: RequiredOTP?,
//TODO IMPORTANT: remove in production
val otpCode: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class LoginService(
return TokenResponse(token, RequiredOTP(usernameType, receiver), res.otp)
}


suspend fun confirmGetToken(request: ConfirmPasswordFlowTokenRequest): TokenResponse {
val username = Username.create(request.username)
val otpRequest = OTPVerifyRequest(username.value, listOf(OTPCode(request.otp, username.type.otpType)))
Expand Down Expand Up @@ -117,7 +118,7 @@ class LoginService(

suspend fun refreshToken(request: RefreshTokenRequest): TokenResponse {
val token = keycloakProxy.refreshUserToken(request.refreshToken, request.clientId, request.clientSecret)
sendLoginEvent(extractUserUuidFromToken(token.accessToken), token.sessionState, request,token.expiresIn)
sendLoginEvent(extractUserUuidFromToken(token.accessToken), token.sessionState, request, token.expiresIn)
return TokenResponse(token, null, null)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ logging:
keycloak:
url: http://keycloak:8080
cert-url: http://keycloak:8080/realms/opex/protocol/openid-connect/certs
iss-url: http://keycloak:8080/realms/opex
iss-url: ${TOKEN_ISSUER_URL:http://keycloak:8080}/realms/opex
realm: opex
admin-client:
id: "opex-admin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ app:
auth:
url: lb://opex-auth
cert-url: http://keycloak:8080/realms/opex/protocol/openid-connect/certs
iss-url: http://keycloak:8080/realms/opex
iss-url: ${TOKEN_ISSUER_URL:http://keycloak:8080}/realms/opex
client-id: none
client-secret: none
wallet:
Expand Down
1 change: 0 additions & 1 deletion common/src/main/kotlin/co/nilin/opex/common/OpexError.kt
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ enum class OpexError(val code: Int, val message: String?, val status: HttpStatus
BankAccountAlreadyExist(13046, "Bank account already exist", HttpStatus.BAD_REQUEST),
BankAccountNotFound(13047, "Bank account not found", HttpStatus.NOT_FOUND),
AddressBookNotFound(13048, "Address book not found", HttpStatus.NOT_FOUND)

;

override fun code() = this.code
Expand Down
9 changes: 8 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ services:
- KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER
- KAFKA_LISTENERS=CLIENT://kafka-2:29092,EXTERNAL://kafka-2:9092,CONTROLLER://kafka-2:29093
- KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CLIENT:PLAINTEXT,EXTERNAL:PLAINTEXT,CONTROLLER:PLAINTEXT

networks:
- default
deploy:
Expand Down Expand Up @@ -351,6 +350,7 @@ services:
- BACKEND_USER=${BACKEND_USER}
- VAULT_HOST=vault
- SYMBOLS=BTC_USDT,ETH_USDT,BTC_IRT,ETH_IRT,USDT_IRT,ETH_BUSD,BTC_BUSD,BNB_BUSD
- TOKEN_ISSUER_URL=${KC_ISSUER_URL}
networks:
- default
depends_on:
Expand Down Expand Up @@ -404,6 +404,7 @@ services:
- CONSUL_HOST=consul
- ADMIN_CLIENT_SECRET=${KC_ADMIN_CLIENT_SECRET}
- PRE_AUTH_CLIENT_SECRET=${KC_PRE_AUTH_CLIENT_SECRET}
- TOKEN_ISSUER_URL=${KC_ISSUER_URL}
volumes:
- auth-gateway-keys:/app/keys
depends_on:
Expand Down Expand Up @@ -432,6 +433,7 @@ services:
- WITHDRAW_OTP_REQUIRED_COUNT=${WITHDRAW_OTP_REQUIRED_COUNT}
- WITHDRAW_BANK_ACCOUNT_VALIDATION=${WITHDRAW_BANK_ACCOUNT_VALIDATION}
- TOTAL_ASSET_CALCULATION_CURRENCY=${TOTAL_ASSET_CALCULATION_CURRENCY}
- TOKEN_ISSUER_URL=${KC_ISSUER_URL}
depends_on:
- kafka-1
- kafka-2
Expand All @@ -456,6 +458,7 @@ services:
- BACKEND_USER=${BACKEND_USER}
- VAULT_HOST=vault
- SWAGGER_AUTH_URL=$KEYCLOAK_FRONTEND_URL
- TOKEN_ISSUER_URL=${KC_ISSUER_URL}
depends_on:
- kafka-1
- kafka-2
Expand Down Expand Up @@ -484,6 +487,7 @@ services:
- TRADE_VOLUME_CALCULATION_CURRENCY=${TRADE_VOLUME_CALCULATION_CURRENCY}
- WITHDRAW_VOLUME_CALCULATION_CURRENCY=${WITHDRAW_VOLUME_CALCULATION_CURRENCY}
- TOTAL_ASSET_CALCULATION_CURRENCY=${TOTAL_ASSET_CALCULATION_CURRENCY}
- TOKEN_ISSUER_URL=${KC_ISSUER_URL}
depends_on:
- consul
- vault
Expand All @@ -506,6 +510,7 @@ services:
- VAULT_HOST=vault
- SWAGGER_AUTH_URL=$KEYCLOAK_FRONTEND_URL
- ADDRESS_EXP_TIME=100
- TOKEN_ISSUER_URL=${KC_ISSUER_URL}
depends_on:
- kafka-1
- kafka-2
Expand Down Expand Up @@ -536,6 +541,7 @@ services:
- SMTP_USER=${SMTP_USER}
- SMTP_PASS=${SMTP_PASS}
- SMTP_FROM=${SMTP_FROM}
- TOKEN_ISSUER_URL=${KC_ISSUER_URL}
depends_on:
- consul
- postgres-otp
Expand All @@ -561,6 +567,7 @@ services:
- JIBIT_SECRET_KEY=${JIBIT_SECRET_KEY}
- ADMIN_APPROVAL_PROFILE_COMPLETION_REQUEST=${ADMIN_APPROVAL_PROFILE_COMPLETION_REQUEST}
- ADMIN_APPROVAL_BANK_ACCOUNT=${ADMIN_APPROVAL_BANK_ACCOUNT}
- TOKEN_ISSUER_URL=${KC_ISSUER_URL}
depends_on:
- kafka-1
- kafka-2
Expand Down
2 changes: 1 addition & 1 deletion market/market-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ logging:
app:
auth:
cert-url: http://keycloak:8080/realms/opex/protocol/openid-connect/certs
iss-url: http://keycloak:8080/realms/opex
iss-url: ${TOKEN_ISSUER_URL:http://keycloak:8080}/realms/opex
custom-message:
enabled: ${CUSTOM_MESSAGE_ENABLED:false}
base-url: ${CUSTOM_MESSAGE_URL}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ app:
url: lb://opex-accountant
auth:
cert-url: http://keycloak:8080/realms/opex/protocol/openid-connect/certs
iss-url: http://keycloak:8080/realms/opex
iss-url: ${TOKEN_ISSUER_URL:http://keycloak:8080}/realms/opex
custom-message:
enabled: ${CUSTOM_MESSAGE_ENABLED:false}
base-url: ${CUSTOM_MESSAGE_URL}
Expand Down
2 changes: 1 addition & 1 deletion otp/otp-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ logging:
app:
auth:
cert-url: http://keycloak:8080/realms/opex/protocol/openid-connect/certs
iss-url: http://keycloak:8080/realms/opex
iss-url: ${TOKEN_ISSUER_URL:http://keycloak:8080}/realms/opex
otp:
sms:
provider:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class AddressBookManagement(
private val addressBookPersister: AddressBookPersister,
) {
suspend fun addAddressBook(uuid: String, request: AddAddressBookItemRequest): AddressBookResponse {
addressBookPersister.findSavedAddress(uuid, request.address, request.addressType)
?.let { return it.toAddressBookResponse() }
return addressBookPersister.save(
AddressBook(
uuid = uuid,
Expand Down
1 change: 1 addition & 0 deletions profile/profile-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ app:
bank-account: ${ADMIN_APPROVAL_BANK_ACCOUNT:false}
auth:
cert-url: http://keycloak:8080/realms/opex/protocol/openid-connect/certs
iss-url: ${TOKEN_ISSUER_URL:http://keycloak:8080}/realms/opex
kyc:
url: lb://opex-kyc/v2/admin/kyc/internal
otp:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import co.nilin.opex.profile.core.data.profile.AddressBook

interface AddressBookPersister {

suspend fun save(addressBook: AddressBook) : AddressBook
suspend fun save(addressBook: AddressBook): AddressBook
suspend fun findAll(uuid: String): List<AddressBook>
suspend fun update(addressBook: AddressBook) : AddressBook
suspend fun update(addressBook: AddressBook): AddressBook
suspend fun delete(uuid: String, id: Long)
suspend fun findSavedAddress(uuid: String, address: String, adressType: String): AddressBook?

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import org.springframework.data.r2dbc.repository.Query
import org.springframework.data.repository.reactive.ReactiveCrudRepository
import org.springframework.stereotype.Repository
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono

@Repository
interface AddressBookRepository : ReactiveCrudRepository<AddressBookModel, Long> {

@Query("select * from address_book where uuid = :uuid")
suspend fun findAllByUuid(uuid: String): Flux<AddressBook>
suspend fun findByUuidAndAddressAndAddressType(uuid: String, address: String, type: String): Mono<AddressBook>?

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ class AddressBookManagementImp(
addressBookRepository.deleteById(id).awaitFirstOrNull()
else throw OpexError.Forbidden.exception()
}

override suspend fun findSavedAddress(uuid: String, address: String, addressType: String): AddressBook? {
return addressBookRepository.findByUuidAndAddressAndAddressType(uuid, address, addressType)?.awaitFirstOrNull()
}
}
2 changes: 1 addition & 1 deletion wallet/wallet-app/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ app:
auth:
url: lb://opex-auth
cert-url: http://keycloak:8080/realms/opex/protocol/openid-connect/certs
iss-url: http://keycloak:8080/realms/opex
iss-url: ${TOKEN_ISSUER_URL:http://keycloak:8080}/realms/opex
client-id: none
client-secret: none
system:
Expand Down
Loading