Implement Two-Factor Authentication - #720
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces end-to-end two-factor authentication (2FA) support in the auth-gateway, including TOTP (authenticator app) flows backed by the OTP service, and extends OTP requests with an action context (REGISTER/LOGIN/FORGET/TWO_FACTOR).
Changes:
- Added user-facing 2FA endpoints and service logic to enable/disable 2FA and to set up/verify TOTP.
- Extended OTP proxying to include an optional
actionand added resend OTP endpoints for registration and forgot-password flows. - Updated OTP/TOTP query responses to include a TOTP URI and added app name configuration for TOTP labeling.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| otp/otp-app/src/main/kotlin/co/nilin/opex/otp/app/service/TOTPService.kt | Returns richer TOTP query response including a generated otpauth URI. |
| otp/otp-app/src/main/kotlin/co/nilin/opex/otp/app/model/TOTPQueryResponse.kt | Adds uri to the TOTP query response model. |
| otp/otp-app/src/main/kotlin/co/nilin/opex/otp/app/controller/TOTPController.kt | Simplifies query endpoint to return the service response directly. |
| docker-compose.yml | Wires APP_NAME env var into auth-gateway container. |
| common/src/main/kotlin/co/nilin/opex/common/OpexError.kt | Adds InvalidOTPType error for 2FA flows. |
| auth-gateway/auth-gateway-app/src/main/resources/application.yml | Adds app.name configuration with default value. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/service/TwoFactorConfigService.kt | New service implementing enable/disable 2FA and TOTP setup/verification. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/service/RegisterService.kt | Adjusts registration OTP request flow and adds resend registration OTP. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/service/LoginService.kt | Updates login flow to support per-user 2FA method incl. TOTP and OTP action tagging. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/service/ForgetPasswordService.kt | Adds OTP action tagging and resend forgot-password OTP. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/proxy/OTPProxy.kt | Adds action to OTP requests and adds TOTP endpoints (setup/query/verify). |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/proxy/KeycloakProxy.kt | Adds user lookup by UUID and OTP attribute update support; adjusts user creation defaults. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/model/UserRegister.kt | Removes first/last name from register request payload. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/model/TwoFactor.kt | Adds request/response DTOs for 2FA endpoints. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/model/TOTP.kt | Adds DTOs for TOTP setup/query/verify payloads. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/model/OTP.kt | Extends OTPAction enum to cover login and 2FA. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/controller/UserTwoFactorConfigController.kt | New authenticated endpoints for 2FA config and TOTP setup/verify. |
| auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/controller/PublicUserController.kt | Adds public resend-OTP endpoints for register/forget flows. |
Suppressed comments (1)
auth-gateway/auth-gateway-app/src/main/kotlin/co/nilin/opex/auth/proxy/KeycloakProxy.kt:431
updateOtpConfig()setsAttributes.OTPto a rawString, butattributesare modeled/handled asMap<String, List<String>>. This can cause Keycloak update requests to fail or later reads to misinterpret the OTP config.
Wrap the value in a single-element list.
suspend fun updateOtpConfig(
userId: String,
otpConfig: String
) {
updateUserFields(
userId = userId,
updates = mapOf(
"attributes" to mapOf(
Attributes.OTP to otpConfig
)
)
)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Copilot stopped reviewing on behalf of
fatemeh-i due to an error
August 17, 2026 14:38
Hossein-ab99
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.