From d812b1cc5f6bf2992c09abd564dea3c3e3368a5d Mon Sep 17 00:00:00 2001 From: fatemeh imanipour Date: Sat, 9 May 2026 16:17:00 +0330 Subject: [PATCH 1/2] Add interceptors dependency to all related modules --- accountant/accountant-app/pom.xml | 4 ++++ accountant/pom.xml | 5 +++++ auth-gateway/auth-gateway-app/pom.xml | 4 ++++ bc-gateway/bc-gateway-app/pom.xml | 8 ++++++++ device-management/device-management-app/pom.xml | 4 ++++ device-management/pom.xml | 5 +++++ docker-compose.yml | 4 ++-- matching-gateway/matching-gateway-app/pom.xml | 4 ++++ otp/otp-app/pom.xml | 4 ++++ profile/pom.xml | 5 +++++ profile/profile-app/pom.xml | 4 ++++ user-management/pom.xml | 5 +++++ 12 files changed, 54 insertions(+), 2 deletions(-) diff --git a/accountant/accountant-app/pom.xml b/accountant/accountant-app/pom.xml index 67649ff75..f56aee06a 100644 --- a/accountant/accountant-app/pom.xml +++ b/accountant/accountant-app/pom.xml @@ -51,6 +51,10 @@ co.nilin.opex.utility error-handler + + co.nilin.opex.utility + interceptors + org.springframework.cloud spring-cloud-starter-vault-config diff --git a/accountant/pom.xml b/accountant/pom.xml index 6eded39f6..edce57a88 100644 --- a/accountant/pom.xml +++ b/accountant/pom.xml @@ -82,6 +82,11 @@ error-handler ${error-hanlder.version} + + co.nilin.opex.utility + interceptors + ${interceptor.version} + org.springframework.cloud spring-cloud-dependencies diff --git a/auth-gateway/auth-gateway-app/pom.xml b/auth-gateway/auth-gateway-app/pom.xml index 0d31ffddd..0ff3a5ade 100644 --- a/auth-gateway/auth-gateway-app/pom.xml +++ b/auth-gateway/auth-gateway-app/pom.xml @@ -80,6 +80,10 @@ co.nilin.opex.utility error-handler + + co.nilin.opex.utility + interceptors + com.auth0 java-jwt diff --git a/bc-gateway/bc-gateway-app/pom.xml b/bc-gateway/bc-gateway-app/pom.xml index 2bdccb667..0046a178b 100644 --- a/bc-gateway/bc-gateway-app/pom.xml +++ b/bc-gateway/bc-gateway-app/pom.xml @@ -138,6 +138,14 @@ micrometer-registry-prometheus runtime + + co.nilin.opex.utility + interceptors + + + co.nilin.opex.utility + error-handler + diff --git a/device-management/device-management-app/pom.xml b/device-management/device-management-app/pom.xml index 82e41ff4e..ff9b70048 100644 --- a/device-management/device-management-app/pom.xml +++ b/device-management/device-management-app/pom.xml @@ -78,6 +78,10 @@ co.nilin.opex.utility error-handler + + co.nilin.opex.utility + interceptors + com.zaxxer HikariCP diff --git a/device-management/pom.xml b/device-management/pom.xml index d24596637..4800bfa7c 100644 --- a/device-management/pom.xml +++ b/device-management/pom.xml @@ -56,6 +56,11 @@ error-handler ${error-hanlder.version} + + co.nilin.opex.utility + interceptors + ${interceptor.version} + co.nilin.opex.device-management device-management-core diff --git a/docker-compose.yml b/docker-compose.yml index 63535e6e2..b9078536e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -546,8 +546,8 @@ services: - SMTP_USER=${SMTP_USER} - SMTP_PASS=${SMTP_PASS} - SMTP_FROM=${SMTP_FROM} - - SMTP_SOCKS_HOST=${SMTP_SOCKS_HOST} - - SMTP_SOCKS_PORT=${SMTP_SOCKS_PORT} + - SMTP_PROXY_HOST=${SMTP_PROXY_HOST} + - SMTP_PROXY_PORT=${SMTP_PROXY_PORT} - SMTP_PROXY_ENABLED=${SMTP_PROXY_ENABLED} - TOKEN_ISSUER_URL=${KC_ISSUER_URL} - OTP_CODE_RESPONSE_ENABLED=${OTP_CODE_RESPONSE_ENABLED} diff --git a/matching-gateway/matching-gateway-app/pom.xml b/matching-gateway/matching-gateway-app/pom.xml index 24e94ab58..86d029320 100644 --- a/matching-gateway/matching-gateway-app/pom.xml +++ b/matching-gateway/matching-gateway-app/pom.xml @@ -77,6 +77,10 @@ co.nilin.opex.utility error-handler + + co.nilin.opex.utility + interceptors + io.mockk mockk diff --git a/otp/otp-app/pom.xml b/otp/otp-app/pom.xml index 1d3d72124..49cb4f0c0 100644 --- a/otp/otp-app/pom.xml +++ b/otp/otp-app/pom.xml @@ -87,6 +87,10 @@ co.nilin.opex.utility error-handler + + co.nilin.opex.utility + interceptors + io.mockk mockk diff --git a/profile/pom.xml b/profile/pom.xml index 7ac615097..ffd3ab564 100644 --- a/profile/pom.xml +++ b/profile/pom.xml @@ -66,6 +66,11 @@ logging-handler ${logging-handler.version} + + co.nilin.opex.utility + error-handler + ${error-hanlder.version} + co.nilin.opex.utility interceptors diff --git a/profile/profile-app/pom.xml b/profile/profile-app/pom.xml index 685459a22..2b2412044 100644 --- a/profile/profile-app/pom.xml +++ b/profile/profile-app/pom.xml @@ -98,6 +98,10 @@ org.springframework.cloud spring-cloud-starter-vault-config + + co.nilin.opex.utility + error-handler + co.nilin.opex.utility interceptors diff --git a/user-management/pom.xml b/user-management/pom.xml index 0c0b0c5a4..fbb1146c0 100644 --- a/user-management/pom.xml +++ b/user-management/pom.xml @@ -49,6 +49,11 @@ error-handler ${error-hanlder.version} + + co.nilin.opex.utility + interceptors + ${interceptor.version} + co.nilin.opex.auth user-management-core From 0b5a987ab60054ae3f2b24e1c32c54f69aea5914 Mon Sep 17 00:00:00 2001 From: Amir Rajabi Date: Thu, 23 Jul 2026 14:24:12 +0330 Subject: [PATCH 2/2] Refactor auth token extraction in SessionController --- .../opex/api/core/inout/auth/UserRegister.kt | 3 +++ .../opex/controller/SessionController.kt | 20 +++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/api/api-core/src/main/kotlin/co/nilin/opex/api/core/inout/auth/UserRegister.kt b/api/api-core/src/main/kotlin/co/nilin/opex/api/core/inout/auth/UserRegister.kt index a847316aa..917fcd1fd 100644 --- a/api/api-core/src/main/kotlin/co/nilin/opex/api/core/inout/auth/UserRegister.kt +++ b/api/api-core/src/main/kotlin/co/nilin/opex/api/core/inout/auth/UserRegister.kt @@ -1,5 +1,7 @@ package co.nilin.opex.api.core.inout.auth +import com.fasterxml.jackson.annotation.JsonIgnoreProperties + data class RegisterUserRequest( val username: String, val firstName: String? = null, @@ -8,6 +10,7 @@ data class RegisterUserRequest( val captchaCode: String, ) +@JsonIgnoreProperties(ignoreUnknown = true) data class VerifyOTPRequest( val username: String, val otp: String, diff --git a/api/api-ports/api-opex-rest/src/main/kotlin/co/nilin/opex/api/ports/opex/controller/SessionController.kt b/api/api-ports/api-opex-rest/src/main/kotlin/co/nilin/opex/api/ports/opex/controller/SessionController.kt index db6bcce48..cd9496bbd 100644 --- a/api/api-ports/api-opex-rest/src/main/kotlin/co/nilin/opex/api/ports/opex/controller/SessionController.kt +++ b/api/api-ports/api-opex-rest/src/main/kotlin/co/nilin/opex/api/ports/opex/controller/SessionController.kt @@ -3,8 +3,8 @@ package co.nilin.opex.api.ports.opex.controller import co.nilin.opex.api.core.inout.auth.SessionRequest import co.nilin.opex.api.core.inout.auth.Sessions import co.nilin.opex.api.core.spi.AuthProxy -import co.nilin.opex.common.OpexError -import co.nilin.opex.common.security.jwtAuthentication +import co.nilin.opex.api.ports.opex.util.jwtAuthentication +import co.nilin.opex.api.ports.opex.util.tokenValue import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.enums.ParameterIn @@ -42,8 +42,7 @@ Response body: No response body.""", security = [SecurityRequirement(name = "bea suspend fun logout( @Parameter(hidden = true) @CurrentSecurityContext securityContext: SecurityContext ) { - val userId = securityContext.jwtAuthentication().name - authProxy.logout(userId) + authProxy.logout(securityContext.jwtAuthentication().tokenValue()) } @PostMapping("/session") @@ -71,9 +70,7 @@ Allowed values: @Parameter(hidden = true) @CurrentSecurityContext securityContext: SecurityContext, @RequestBody sessionRequest: SessionRequest ): List { - val uuid = securityContext.authentication.name - sessionRequest.uuid = uuid - return authProxy.getSessions(sessionRequest, uuid) + return authProxy.getSessions(sessionRequest, securityContext.jwtAuthentication().tokenValue()) } @DeleteMapping("/session/{sessionId}") @@ -96,8 +93,7 @@ Response body: No response body.""", security = [SecurityRequirement(name = "bea @Parameter(hidden = true) @CurrentSecurityContext securityContext: SecurityContext, @PathVariable sessionId: String ) { - val uuid = securityContext.authentication.name - authProxy.logout(uuid, sessionId) + authProxy.logout(sessionId, securityContext.jwtAuthentication().tokenValue()) } @PostMapping("/session/delete-others") @@ -117,8 +113,7 @@ Response body: No response body.""", security = [SecurityRequirement(name = "bea suspend fun logoutOthers( @Parameter(hidden = true) @CurrentSecurityContext securityContext: SecurityContext ) { - val uuid = securityContext.authentication.name - authProxy.logoutOthers(uuid) + authProxy.logoutOthers(securityContext.jwtAuthentication().tokenValue()) } @PostMapping("/session/delete-all") @@ -138,7 +133,6 @@ Response body: No response body.""", security = [SecurityRequirement(name = "bea suspend fun logoutAll( @Parameter(hidden = true) @CurrentSecurityContext securityContext: SecurityContext ) { - val uuid = securityContext.authentication.name - authProxy.logoutAll(uuid) + authProxy.logoutAll(securityContext.jwtAuthentication().tokenValue()) } }