Add application password authorization flow to wp-login.php#551
Add application password authorization flow to wp-login.php#551obenland wants to merge 7 commits intoWordPress:trunkfrom
Conversation
…n.php. Provides a login-based authorization flow for creating application passwords, gated by a UUID-based app allowlist. After approval, renders the MCP client configuration for easy copy-paste setup.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
@dd32 When you get a chance, I'd appreciate any feedback you have on this. Naming, file location, stuff I missed, anything. Thank you! |
There was a problem hiding this comment.
Pull request overview
Adds an application-password authorization flow to wp-login.php?action=authorize_application for a UUID-allowlisted set of apps, enabling users to approve/reject and (for the MCP app) obtain a ready-to-copy MCP client configuration.
Changes:
- Introduces a new
login_form_authorize_applicationhandler that validates requests, renders an approval form, and creates/revokes application passwords. - Adds login-page contextual messaging and custom styling for the new action.
- Renders an MCP client configuration (with copy button + client notes) after approval for the allowlisted MCP app.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wordpress.org/public_html/wp-content/mu-plugins/pub/authorize-application-login.php
Outdated
Show resolved
Hide resolved
wordpress.org/public_html/wp-content/mu-plugins/pub/authorize-application-login.php
Show resolved
Hide resolved
Guard wporg_render_mcp_config with an app_id check so it only renders for the WordPress.org MCP application, not for any other app that may be added to the allowlist in the future.
…ison. Remove redundant urlencode() calls in add_query_arg() which already handles encoding internally. Normalize hostnames to lowercase before comparing against the allowlist since DNS is case-insensitive.
…ress.org. Only load the mu-plugin on blog ID 350 (login.wordpress.org) so the authorization flow is not available on other sites in the multisite.
…ation-passwords.php.
dd32
left a comment
There was a problem hiding this comment.
As for code location.. I don't really mind where this lives. This seems like something that could be upstreamed to WordPress core perhaps, as a front-end UI for the existing wp-admin authorize application flow. It seems this has a few things in it that are very WordPress.org specific, and that's OK.
wporg-sso plugin has a bunch of logic related to login in it. I don't really like that.
wporg-login theme has a bunch of logic in it. I also don't really like that.
I assume this is intentionally open to accepting literally any redirect location at present, and that we might look at changing it to a more strict host set before deploy? Otherwise, what's the point of an application allow list.. the UUIDs would be public knowledge..
wordpress.org/public_html/wp-content/mu-plugins/pub/login-application-passwords.php
Outdated
Show resolved
Hide resolved
wordpress.org/public_html/wp-content/mu-plugins/pub/login-application-passwords.php
Show resolved
Hide resolved
wordpress.org/public_html/wp-content/mu-plugins/pub/login-application-passwords.php
Outdated
Show resolved
Hide resolved
wordpress.org/public_html/wp-content/mu-plugins/pub/login-application-passwords.php
Show resolved
Hide resolved
wordpress.org/public_html/wp-content/mu-plugins/pub/login-application-passwords.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Dion Hulse <dd32@dd32.id.au>
Each app in the allowlist has a hosts array that controls which domains |
…uthorization. Encode values passed to add_query_arg() to match core's authorize-application.php, use null-coalesce consistently, and remove redundant comment.
@obenland OH! I didn't realise it just then prompted, I was thinking it just allowed an open-redirect with no hosts 🙃 which as you can imagine... concerned me :) |
|
Yeah, I think that's how the current Core version works. The form shows the URL that it'll redirect to, but it mostly seems to rely on users knowing what they're doing |
Summary
Adds an
authorize_applicationaction towp-login.phpthat lets users create application passwords through the login flow. Requests are validated against a UUID-based allowlist. After approval, the MCP client configuration is rendered with a copy button for easy setup.Not sure if this UUID-gating is strictly needed but I thought I'd be a bit conservative to start out with.
I suppose at some point we'd want an application password management UI in profiles.wordpress.org.
Login prompt
When visiting the authorization URL while logged out, a contextual message is shown:
Authorization form
After logging in, the user can approve or reject the connection:
MCP configuration
On approval, the ready-to-use MCP client config is displayed with per-client setup instructions:
TODO
login.wordpress.org.Test plan
wp-login.php?action=authorize_application&app_id=c4c73a54-96d7-47b9-9bdc-1a66b9b04505while logged out and verify redirect to login form with contextual message.app_idis rejected.success_urlorreject_urlfor the MCP app (which has empty hosts) is rejected.