Connector Approval experiment to limit what plugins can access what connectors#467
Conversation
… pending requests
… and what is approved
…ve access to the option
… and update approvals
… of pre option filters, since the AI Client grabs options prior to plugins making requests, meaning we can't accurately filter there. Make a handful of changes to support this
…er through as well. Ensure we don't require approval for a provider that doesn't exist
…ing of provider name to api key to determine which provider is being used
…own; add E2E tests
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @addedlovely. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #467 +/- ##
=============================================
- Coverage 73.18% 73.04% -0.14%
- Complexity 1527 1729 +202
=============================================
Files 77 85 +8
Lines 6873 7461 +588
=============================================
+ Hits 5030 5450 +420
- Misses 1843 2011 +168
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ized into URL query strings still attribute correctly, prefer the plugin basename matching the calling frame's file when a directory registers multiple plugin header files, and return 404 from delete_pending when the pending key is unknown instead of silently re-rendering state.
|
(I didn't have a chance to pull down and test but wanted to say that this looks super cool and exciting. Does the matrix scale for more than 3 connectors? ) |
In diving into this more today, this secrets manager is interesting but I don't think fully solves the problem we were discussing. In essence, it provides a standardized way to encrypt and decrypt data in WordPress, allowing us to encrypt API keys before saving and decrypt them when we need to make a request. I think that's sorely needed in WordPress (and there is already a Trac ticket open around this for the Connectors API) but still doesn't solve the issue of preventing someone from accessing an API key a site owner doesn't want them to have. That said, if we were to add this alongside what's already in this PR, that does get us closer to a "secure" state. But there are still edge cases, like a plugin directly pulling the API key out of the database or just using our built-in encryption/decryption methods that we would need to add. I'm not sure there's a way for us in a plugin to 100% cover all bases. My suggestion here would be to proceed with this PR (and any feedback given) but then open a separate PR to look at integrating encryption (either with that Secrets Manager or a custom approach). I don't think these two need to be shipped within the same PR and I'm cognizant at the large size of this PR already. |
How does this work? Plugins and themes by nature have complete unrestricted access to WordPress, they could just circumvent this. |
Correct, only so much we can do here from within another plugin. At a high-level, we hook into But yes, nothing stopping another plugin from hooking in earlier, removing our hook or making a direct curl request and not using the WP HTTP API at all. This isn't meant to be 100% effective (or I should say I don't think it's possible to be 100% effective), it's meant more as a PoC that can hopefully stir conversation about getting something more permanent in WordPress Core itself. |
|
I built a small plugin exploring plugin-level AI Client access control (probably that's why I was tagged here too), so I wanted to share a few implementation tradeoffs from that work https://wordpress.org/plugins/handl-ai-connector-access-control/#is%20attribution%20perfect%3F. My approach used Longer term, I think the ideal API would be a higher-level AI Client/Connector hook that passes the resolved connector/provider, caller identity, and request capability before execution. That would avoid both SDK reflection and credential scanning. A few smaller points:
|
Yeah, my initial exploration used
Yep, I agree and added those thoughts on the original issue.
Good question and this is where I'd love some more testing. I didn't run into any unidentified callers in my testing but if that's a common occurrence, likely need to decide if those should be allowed through or not. I'd lean towards allowing them in as part of this exploration work as this is meant as an experiment but open to opinions on that.
We have #437 open right now that adds logging. That PR and this PR will work nicely together
I debated whether I should look at themes but I know some themes add in quite a bit of functionality so likely there will be some that try and make AI requests. That said, I did miss having those show in the approval matrix by default so that's likely a good thing to consider adding. |
We might still have time to get something into 7.0 to make the filter more useful, if anyone wants to open a ticket :) |
|
Done in 1d86430
Good call, removed that from showing on that page in 26cd034
Yeah, not something we store right now. Dismissing just removes it from the current view but if the plugin tries making a request again, it will show up again (so dismissing doesn't remove it forever)
Definitely open to design ideas here. I'm not as concerned with the list of plugins/themes as this table can just keep expanding down forever (though maybe there's a better approach). More worried if sites have lots of connectors, there's only so many columns we can show before you have to start scrolling (I would assume this is an edge case and most sites will only have one or two AI connectors)
Right now we use the core If we want this to work for any connector, that's doable though likely better as a follow up as there's probably a few other changes needed. |
|
When the "Connector Approval" experiment setting is enabled, the API key is considered invalid even when the correct key is entered. I didn't understand what was happening until I reached this PR. Is it intended behavior that the API key input itself is put on hold? |
@t-hamano Do you happen to have any other experiments turned on? I could only reproduce this if I had the Request Logging experiment turned on alongside Connector Approval. Otherwise it allows the API key to be validated and saved just fine. Definitely a bug we'll want to fix but curious if that's what you're running into or if you're seeing this with only having the Connector Approval experiment on? |
…onnectors (WordPress#467) Added - Connector Approval experiment, allowing administrators the ability to determine which plugins can access which AI connectors. Unlinked contributors: addedlovely. Co-authored-by: dkotter <dkotter@git.wordpress.org> Co-authored-by: justlevine <justlevine@git.wordpress.org> Co-authored-by: itsgajendraSingh <gajendrasingh@git.wordpress.org> Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org> Co-authored-by: swissspidy <swissspidy@git.wordpress.org> Co-authored-by: haktan-suren <haktansuren@git.wordpress.org> Co-authored-by: HILAYTRIVEDI <hilayt24@git.wordpress.org> Co-authored-by: DarshitRajyaguru <darshitrajyaguru97@git.wordpress.org> Co-authored-by: nikolas4175-godaddy <nikskyverge@git.wordpress.org>

What?
Closes #441, #342
Adds a new settings screen that allows administrators to determine which plugin and theme can access which AI Connectors
Why?
WordPress 7.0 is releasing a new Connectors API that allows users to install various Connector plugins and then configure those once.
There is no approval / permission system in place though, meaning once a Connector is set up, any plugin can then use it even if you don't want that. This PR adds in a new experiment to showcase one approach to adding an approval system.
Worth noting this is (on purpose) a granular approval system. An administrator can decide which plugin has access to which connector, it's not an all or nothing approach.
How?
Connector ApprovalexperimentSettings > AI Connector Approvals). This settings page will show any pending requests and will also show an approval matrix for each active plugin and theme, allowing you to toggle support for each connectorpre_http_requestand determine which plugin/theme is making the request and which provider they are using. If that plugin/theme has not been approved for that provider, stop the requestUse of AI Tools
AI assistance: Yes
Tool(s): Claude Code, Cursor
Model(s): Opus 4.7, GPT-5.3 Codex
Used for: Used Claude Code for initial review and planning. Tried out a number of approaches before finally landing on the current approach. Testing and refinement done by me. Used Cursor to add tests and documentation.
Testing Instructions
npm i && npm run buildSettings > AISettings > AI Connector Approvalsand you should see a pending request for the AI plugin (yes, we even block our own plugin here)Screenshots or screencast
Changelog Entry