Skip to content

PM-26577: Support multiple schemes for Duo, WebAuthn, and SSO callbacks#6339

Draft
david-livefront wants to merge 1 commit intomainfrom
PM-26577-app-links-support
Draft

PM-26577: Support multiple schemes for Duo, WebAuthn, and SSO callbacks#6339
david-livefront wants to merge 1 commit intomainfrom
PM-26577-app-links-support

Conversation

@david-livefront
Copy link
Collaborator

@david-livefront david-livefront commented Jan 8, 2026

🎟️ Tracking

PM-26577

📔 Objective

This PR updates the Duo and WebAuthn logic to send the appropriate deeplink scheme data.

Note: This PR is on hold until the WebConnector logic is updated.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@david-livefront david-livefront added the ai-review Request a Claude code review label Jan 8, 2026
@github-actions github-actions bot added app:password-manager Bitwarden Password Manager app context app:authenticator Bitwarden Authenticator app context t:misc Change Type - ¯\_(ツ)_/¯ and removed ai-review Request a Claude code review labels Jan 8, 2026
.getEncoder()
.encodeToString(json.toString().toByteArray(Charsets.UTF_8))
val parentParam = URLEncoder.encode(CALLBACK_URI, "UTF-8")
val parentParam = URLEncoder.encode(callbackUri, "UTF-8")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parent param is required by the WebAuthn Connector but it does not really use the value.

I have an open question about what I should be sending here.

@david-livefront david-livefront added the ai-review Request a Claude code review label Jan 8, 2026
@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 93.81443% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.33%. Comparing base (cbe13d2) to head (64c8a7e).

Files with missing lines Patch % Lines
.../feature/twofactorlogin/TwoFactorLoginViewModel.kt 93.47% 0 Missing and 3 partials ⚠️
...it/bitwarden/data/auth/repository/util/DuoUtils.kt 50.00% 0 Missing and 1 partial ⚠️
...it/bitwarden/data/auth/repository/util/SsoUtils.kt 66.66% 0 Missing and 1 partial ⚠️
...itwarden/data/auth/repository/util/WebAuthUtils.kt 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6339      +/-   ##
==========================================
+ Coverage   86.30%   86.33%   +0.02%     
==========================================
  Files         783      780       -3     
  Lines       56432    56313     -119     
  Branches     8153     8154       +1     
==========================================
- Hits        48705    48616      -89     
+ Misses       4887     4855      -32     
- Partials     2840     2842       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@david-livefront david-livefront force-pushed the PM-26577-app-links-support branch from 795738e to 60679da Compare January 8, 2026 21:53
@github-actions github-actions bot removed the ai-review Request a Claude code review label Jan 8, 2026
@david-livefront david-livefront changed the title PM-26577: Support multiple schemes for Duo and WebAuthn callbacks PM-26577: Support multiple schemes for Duo, WebAuthn, and SSO callbacks Jan 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Logo
Checkmarx One – Scan Summary & Details98bf7d9c-92d2-45b1-9267-f32fcbc9e296

Great job! No new security vulnerabilities introduced in this pull request

@david-livefront david-livefront added the ai-review Request a Claude code review label Jan 8, 2026
@david-livefront david-livefront force-pushed the PM-26577-app-links-support branch from 60679da to fc73da8 Compare January 8, 2026 23:21
@github-actions github-actions bot removed the ai-review Request a Claude code review label Jan 8, 2026
@david-livefront david-livefront force-pushed the PM-26577-app-links-support branch from fc73da8 to 1174c47 Compare January 9, 2026 15:10
@david-livefront david-livefront force-pushed the PM-26577-app-links-support branch from 1174c47 to d702bbf Compare January 26, 2026 18:49
@github-actions github-actions bot removed the t:misc Change Type - ¯\_(ツ)_/¯ label Jan 26, 2026
@david-livefront david-livefront force-pushed the PM-26577-app-links-support branch 3 times, most recently from ffb771d to 375d447 Compare February 6, 2026 16:47
@david-livefront david-livefront added t:feature-tool Change Type - Internal tool feature or enhancement ai-review Request a Claude code review labels Feb 6, 2026
@david-livefront david-livefront force-pushed the PM-26577-app-links-support branch from 375d447 to 3e821aa Compare February 6, 2026 16:50
@github-actions github-actions bot removed the t:feature-tool Change Type - Internal tool feature or enhancement label Feb 6, 2026
@claude
Copy link
Contributor

claude bot commented Feb 6, 2026

Claude finished @david-livefront's task in 4m 7s —— View job


Code Review Summary

PR: PM-26577: Support multiple schemes for Duo, WebAuthn, and SSO callbacks

Overview

This PR updates authentication callback handling to support HTTPS app links (bitwarden.com, bitwarden.eu, bitwarden.pw) in addition to the existing custom bitwarden:// scheme for self-hosted environments. The changes introduce a new AuthTabData model and environment-aware callback URL generation.

Task List

  • Gather context and understand PR changes
  • Review code for issues, bugs, and best practices
  • Post comprehensive review feedback

Findings Summary

Severity Count
❌ Critical 1
⚠️ Issues 1
🎨 Suggestions 5

Critical Issues

The previously identified critical issue with backslash path separators in EnvironmentUrlDataJsonExtensions.kt has been addressed in the latest commit - the paths now correctly use forward slashes.

Remaining Issues

⚠️ Test Expectation Mismatch

File: app/src/test/kotlin/com/x8bit/bitwarden/data/auth/repository/util/WebAuthUtilsTest.kt:26-28

The expected base64 data still uses the old JSON structure. The implementation has changed to include mobile: true and remove callbackUri, but the test expectation hasn't been updated to match.

(This was flagged in a previous review and remains unaddressed)

Code Quality Observations

👍 Well-Designed Architecture

  • The AuthTabData sealed class provides a clean abstraction for handling different scheme types (HTTPS vs custom scheme)
  • Environment-aware callback generation correctly handles US, EU, Internal, and self-hosted scenarios
  • Good separation of concerns between URL building and authentication flow logic

🎨 Suggestions for Improvement

  1. Consider consolidating callback kind constants (EnvironmentUrlDataJsonExtensions.kt)

    • The CallbackKind strings ("duo", "webauthn", "sso") could be defined as constants to prevent typos
  2. Document the parent parameter (WebAuthUtils.kt)

    • The author noted this param is required by WebAuthn Connector but unused - consider adding a KDoc comment explaining this
  3. Coverage gaps (per Codecov report)

    • TwoFactorLoginViewModel.kt - 3 partial lines uncovered
    • DuoUtils.kt, SsoUtils.kt, WebAuthUtils.kt - each has 1 partial line uncovered
    • Consider adding test cases for edge cases in these files

Security Considerations

✅ No security vulnerabilities identified (confirmed by Checkmarx scan)
✅ Callback URLs are environment-specific, preventing cross-environment confusion
✅ HTTPS scheme usage for supported regions improves security over custom schemes


Review by Claude Code ·

EnvironmentRegion.UNITED_STATES -> {
AuthTabData.HttpsScheme(
host = "bitwarden.com",
path = "\\$kind-callback",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: The path uses a backslash (\) instead of a forward slash (/). In Kotlin, "\\$kind-callback" produces \duo-callback, but URL paths require forward slashes.

This will cause malformed callback URLs like https://bitwarden.com\duo-callback instead of https://bitwarden.com/duo-callback, breaking authentication callbacks for Duo, WebAuthn, and SSO flows.

Suggested change
path = "\\$kind-callback",
path = "/$kind-callback",

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude This has been fixed

Copy link
Contributor

@claude claude bot Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude finished @david-livefront's task in 19s —— View job


Verifying Fix

  • Verify the backslash path fix in EnvironmentUrlDataJsonExtensions.kt

Confirmed! The fix looks good. The path now correctly uses "$kind-callback" without the backslash:

AuthTabData.HttpsScheme(
    host = "bitwarden.com",
    path = "$kind-callback",
)

This will produce valid URL paths like duo-callback, webauthn-callback, and sso-callback.

Comment on lines 26 to 28
"?data=eyJjYWxsYmFja1VyaSI6ImJpdHdhcmRlbjovL3dlYmF1dGhuLWNhbGxiYWNrIiwiZ" +
"GF0YSI6Int9IiwiaGVhZGVyVGV4dCI6ImhlYWRlciIsImJ0blRleHQiOiJidXR0b24iLCJi" +
"dG5SZXR1cm5UZXh0IjoicmV0dXJuQnV0dG9uIn0=" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ IMPORTANT: The expected base64 data does not match the current implementation. The JSON structure has changed:

Old (in test): {"callbackUri":"bitwarden://webauthn-callback","data":"{}","headerText":"header","btnText":"button","btnReturnText":"returnButton"}

New (in code): {"data":"{}","headerText":"header","btnText":"button","btnReturnText":"returnButton","mobile":true}

The test expectation needs to be updated to match the new JSON structure that the generateUriForWebAuth function now produces.

@david-livefront david-livefront force-pushed the PM-26577-app-links-support branch from 3e821aa to 64c8a7e Compare February 6, 2026 20:46
): LoginResult = identityService
.getToken(
uniqueAppId = authDiskSource.uniqueAppId,
deeplinkScheme = environmentRepository.environment.environmentUrlData.appLinksScheme,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed specifically for Duo support, since the server generates the redirect url.
The property is fully ignored if the user does not have Duo configured but we do not know that at this time so we must always send it.

is AuthTabData.HttpsScheme -> {
AuthTabIntent.Builder()
.build()
.launch(launcher, uri, authTabData.host, "\\${authTabData.path}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: The path parameter uses a backslash (\\) instead of a forward slash (/). In Kotlin, "\\${authTabData.path}" produces \duo-callback (with a literal backslash), but URL paths require forward slashes.

This will cause the AuthTab to register callbacks with malformed paths like \duo-callback instead of /duo-callback, breaking authentication redirect verification for Duo, WebAuthn, and SSO flows when using HTTPS app links on devices that support AuthTab.

Suggested change
.launch(launcher, uri, authTabData.host, "\\${authTabData.path}")
.launch(launcher, uri, authTabData.host, "/${authTabData.path}")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude This has been addressed

Copy link
Contributor

@claude claude bot Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude finished @david-livefront's task in 1m 0s —— View job


Verification Status

  • Verify the backslash issue has been fixed in IntentManagerImpl.kt

Thanks for the update! However, I'm still seeing the backslash in the current code at IntentManagerImpl.kt:97:

.launch(launcher, uri, authTabData.host, "\\${authTabData.path}")

The current commit on the PR branch is 64c8a7e and still contains "\\${authTabData.path}".

If you've committed a fix locally, it may not have been pushed yet. The path should use a forward slash:

.launch(launcher, uri, authTabData.host, "/${authTabData.path}")

Let me know if you'd like me to make this fix, or if there's a pending push I should wait for!

@david-livefront david-livefront added the t:feature-tool Change Type - Internal tool feature or enhancement label Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review app:authenticator Bitwarden Authenticator app context app:password-manager Bitwarden Password Manager app context t:feature-tool Change Type - Internal tool feature or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant