Allow headless application-password creation on Atomic sites#22885
Open
jkmassel wants to merge 1 commit into
Open
Allow headless application-password creation on Atomic sites#22885jkmassel wants to merge 1 commit into
jkmassel wants to merge 1 commit into
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## jkmassel/issue-22884-list-screen-direct-host #22885 +/- ##
================================================================================
+ Coverage 37.32% 37.33% +0.01%
================================================================================
Files 2320 2321 +1
Lines 124580 124644 +64
Branches 16926 16938 +12
================================================================================
+ Hits 46498 46538 +40
- Misses 74321 74342 +21
- Partials 3761 3764 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
1888111 to
912dd2e
Compare
This was referenced May 25, 2026
912dd2e to
a123523
Compare
3 tasks
Fixes #22884. `ApplicationPasswordsManager.getApplicationCredentials` returned `NotSupported` for any `site.isWPCom` site. The guard was correct for Simple sites but blocked Atomic sites, which are also `isWPCom`-flagged and do support REST application-password creation. Users on Atomic saw the "Authenticate using Application Password" card on My Site and had to authorize through a Chrome Custom Tab even though the app could mint the credential on their behalf. Relax the FluxC guard from `site.isWPCom` to `site.isWPComSimpleSite` and add a uniform validate-then-mint pipeline to `ApplicationPasswordViewModelSlice`: validate stored creds via wordpress-rs Basic auth against the direct host (new `ApplicationPasswordValidator`, using `WpApiClientProvider.getApplicationPasswordClient` from #22894); on Invalid, clear them via a new `SiteStore.deleteStoredApplicationPasswordCredentials` and fall through to mint via a new `SiteStore.createApplicationPassword` (FluxC Jetpack tunnel); on mint failure, the existing discovery + card path takes over. The XML-RPC-disabled card path is now gated on `!isUsingWpComRestApi` so it only fires for true self-hosted sites. Also provides the missing `@ApplicationPasswordsClientId` Dagger binding — without it any call into `ApplicationPasswordsStore` threw `NoSuchElementException`. The path was latent on these apps until the auto-mint above started routing My Site through it.
dc9ff28 to
cc93500
Compare
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.


Description
Fixes #22884.
Problem
ApplicationPasswordsManager.getApplicationCredentialsreturnedNotSupportedfor anysite.isWPComsite. The guard was correct for Simple sites but blocked Atomic sites, which are alsoisWPCom-flagged and do support REST application-password creation. Users on Atomic saw the "Authenticate using Application Password" card on My Site and had to authorize through a Chrome Custom Tab even though the app could mint the credential on their behalf.What changed
Relax the FluxC guard (
ApplicationPasswordsManager.kt:45):site.isWPCom→site.isWPComSimpleSite. Atomic falls through to the existingorigin == ORIGIN_WPCOM_RESTbranches and the Jetpack-tunnelJetpackApplicationPasswordsRestClient.Auto-mint before showing the card (
ApplicationPasswordViewModelSlice+ newSiteStore.createApplicationPassword): before rendering the "Authenticate" card, attempt headless creation via the FluxC manager. On success, persist credentials onto the SiteModel (sositeHasBadCredentialsflips false) and skip the card. On failure, fall back to the existing discovery + Custom Tab card.Fix the launch crash (
ApplicationPasswordsClientIdModule+SiteStoreguard): the WordPress / Jetpack apps had never bound@ApplicationPasswordsClientIdin their Dagger graphs, so any call intoApplicationPasswordsStorethrewNoSuchElementException. This was latent — no production caller hit the path on these apps — until step 2 above started routing My Site through it and crashed the app on launch. Provide the binding with the same device-interpolated name the Custom Tab flow already uses ("Jetpack Android App on <device>"/"WordPress Android App on …"); also short-circuitSiteStore.createApplicationPasswordtoNotSupportedwhen the configuration is disabled, so we degrade gracefully if the binding goes missing again.Validate-then-mint pipeline (new
ApplicationPasswordValidator, slice restructure): collapse the previousisUsingSelfHostedRestApi → validatevselse → discovery+cardsplit into a single uniformvalidate → mint → cardflow that works for every site type.The validator hits
users().retrieveMeWithViewContext()viaWpApiClientProvider.getApplicationPasswordClient(site)(introduced in Route the application-passwords list screen through Basic auth #22894) — always Basic auth against the direct host. The previous validation went throughgetWpApiClient, which for Atomic returns the WPCom bearer client and never actually exercised the application password, so revoked passwords on Atomic were undetectable. OnInvalid, the slice clears stored creds via a newSiteStore.deleteStoredApplicationPasswordCredentialsand falls through to mint; onNetworkUnavailable, the card stays hidden.The mint step calls
SiteStore.createApplicationPasswordfrom item 2. The card step shows the reauth banner if we started with creds, the "authenticate" card otherwise — either way discovery still populates the Custom Tab URL.The XML-RPC-disabled card path is now gated on
!isUsingWpComRestApiso it only fires for true self-hosted sites — Atomic and Jetpack-WPCom-REST sites talk REST end-to-end.Site type coverage
trunk)The "revoke and recover" Atomic case is covered by #22893.
On-device verification
Confirmed against
jeremyseriousbusinesstesting.wpcomstaging.com(Atomic):Tests
Adds two FluxC manager cases (simple-WPCom
NotSupported; Atomic Jetpack-tunnel mint) inApplicationPasswordManagerTests, six slice cases inApplicationPasswordViewModelSliceTestcovering the new validate → mint → card flow, and a small standaloneOnApplicationPasswordCreateErrorTestfor the FluxC error class.Testing instructions
Atomic happy path — first foreground
adb logcat -s WordPress-MAIN | grep A_P:) showsHeadless mint succeeded.Jetpack Android App on <your device>.Atomic — subsequent loads with valid creds
A_P: Validation Success returned user id=...followed byHiding card for ... - authenticated. No re-mint attempt.Simple WPCom regression
NotSupportedand discovery returning empty.Self-hosted regression (true self-hosted, not Atomic)
Out of scope here (covered by #22893)
These scenarios will not behave correctly against PR2 alone — the validator's classification still has the issues found during the initial on-device testing of this PR:
NetworkUnavailableforincorrect_passwordand the card stays silently hidden instead of triggering a re-mint or reauth banner.Invalidand wipes stored credentials.DeviceIsOfflineErrorasInvalidand wipes stored credentials.If you want to exercise the full revoke-and-recover flow on-device, build from the
jkmassel/issue-22884-validator-hardeningbranch (or check out #22893's head).Related
application-passwordscreation routes, so wordpress-rs can't replace FluxC for this mint today. Filed during this PR.