Commit 14a65bc
authored
Route the application-passwords list screen through Basic auth (#22894)
* Add getApplicationPasswordClient to WpApiClientProvider
Companion to `getWpApiClient` that always returns a direct-host
Basic-auth client built from the SiteModel's application-password
credentials, regardless of WP.com routing. `getWpApiClient` sends
WPCom-flagged sites (including Atomic) through the bearer-token
path and the WP.com REST proxy, which doesn't expose all of the
application-password-authenticated routes. The list-screen change
in the next commit needs to talk to the direct host; the auto-mint
+ validator work in the headless-creation PR uses this same method.
* Route the application-passwords list screen through Basic auth
`ApplicationPasswordsViewModel.getApplicationPasswordsList` called
`WpApiClientProvider.getWpApiClient(site)`, which for any WPCom-flagged
site (including Atomic) routes through the WP.com REST proxy. That
proxy doesn't expose the `application-passwords` routes — every
request 404s with `rest_no_route`, the same upstream wordpress-rs
limitation that drove dropping the headless mint attempt in this
project (Automattic/wordpress-rs#1350). As a result, the list screen
appeared empty / errored on Atomic sites: `getCurrentUserId` would
404, return null, and `getApplicationPasswordsList` would early-return
an empty list.
Switch to `WpApiClientProvider.getApplicationPasswordClient(site)`,
which always builds a direct-host Basic-auth client from the stored
application-password credentials. The direct host serves the
`application-passwords` routes on every WordPress install, so the
listing call works for Atomic and Jetpack-WPCom-REST sites in
addition to true self-hosted.
For self-hosted, behavior is unchanged: both client providers route
self-hosted sites through `selfHostedClients.getOrPut(site.id) {
createSelfHostedClient(site, ...) }`, returning the same Basic-auth
client.
Precondition: the SiteModel must already have credentials —
typically populated by the My Site auto-mint flow on first foreground.
A user reaching the list screen without ever visiting My Site would
401 instead of seeing an empty screen. That edge case can be handled
separately (e.g. by minting on demand here) and is out of scope.1 parent 82411a0 commit 14a65bc
2 files changed
Lines changed: 21 additions & 1 deletion
File tree
- WordPress/src/main/java/org/wordpress/android/ui/accounts/applicationpassword
- libs/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpapi/rs
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
190 | 196 | | |
191 | 197 | | |
192 | 198 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
73 | 87 | | |
74 | 88 | | |
75 | 89 | | |
| |||
0 commit comments