-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(plugin-mcp): adds custom auth config #14538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
DanRibbens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coulpe considerations
| err: error, | ||
| msg: '[payload-mcp] Custom authentication method failed', | ||
| }) | ||
| throw new APIError('Authentication failed', 401) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want to import UnauthorizedError to throw a translated error message instead of this hard coded one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used AuthenticationError
| : null | ||
|
|
||
| if (apiKey === null) { | ||
| throw new APIError('API Key is required', 401) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, we need to reuse existing errors whenever possible to get translations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used AuthenticationError here as well
| }) | ||
|
|
||
| if (docs.length === 0) { | ||
| throw new AuthenticationError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to give the message: 'The email or password provided is incorrect.' though, I don't think that is right as we're dealing with API keys, right?
Unauthorized error will also give a 401 Unauthorized, with message 'you must be logged in to make this request.'
If neither are what you need then you might need to introduce translations into your plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unauthorized is what we want in this case. I'll export and use that.
DanRibbens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
🚀 This is included in version v3.64.0 |
overrideAuthto the MCP Plugin.MCPAccessSettingsas an exported type from the mcpPluginCustom Auth Behaviors
The bypassed system uses an API Key that contains
MCPAccessSettingsinformation. TheoverrideAuthfunction will bypass the API Key system and use your function when authorizing requests.This means that your function must return a valid
MCPAccessSettingsobject to use.