“如果你不能信任插件,那么你就不能信任整个应用程序。”正因为如此,ChatGPT始终把插件认证放在极为重要的位置上,确保每一个插件都是可靠的、安全的。在ChatGPT中,插件认证机制可以保证用户数据和访问控制的安全。一个好的插件认证机制不仅需要能够验证插件的身份,还需要保护用户的隐私信息,并且确保插件只能访问其被授权的资源。
Plugins offer numerous authentication schemas to accommodate various use cases. To specify the authentication schema for your plugin, use the manifest file. Our plugin domain policy outlines our strategy for addressing domain security issues. For examples of available authentication options, refer to the examples section, which showcases all the different choices.
插件提供了许多身份验证模式以适应各种用例。要指定插件的身份验证模式,请使用清单文件。我们的插件域策略概述了我们解决域安全问题的策略。有关可用身份验证选项的示例,请参阅示例部分,其中展示了所有不同的选项。
Note that the ai-plugin.json
file requires an auth
schema to be set. Even if you elect to use no authentication, it is still required to specify "auth": { "type": "none" }
.
请注意, ai-plugin.json
文件需要设置 auth
模式。即使您选择不使用身份验证,仍然需要指定 "auth": { "type": "none" }
。
We support no-auth flow for applications that do not require authentication, where a user is able to send requests directly to your API without any restrictions. This is particularly useful if you have an open API that you want to make available to everyone, as it allows traffic from sources other than just OpenAI plugin requests.
对于不需要身份验证的应用程序,我们支持无身份验证流,其中用户能够直接向您的API发送请求,而不受任何限制。如果你有一个开放的API,你想让每个人都可以使用,这是特别有用的,因为它允许来自其他来源的流量,而不仅仅是OpenAI插件请求。
"auth": {
"type": "none"
},
If you want to specifically enable OpenAI plugins to work with your API, you can provide a client secret during the plugin installation flow. This means that all traffic from OpenAI plugins will be authenticated but not on a user level. This flow benefits from a simple end user experience but less control from an API perspective.
如果你想专门启用OpenAI插件来与你的API一起工作,你可以在插件安装流程中提供一个客户端密码。这意味着来自OpenAI插件的所有流量都将进行身份验证,但不会在用户级别进行身份验证。此流程受益于简单的最终用户体验,但从API角度来看控制较少。
"auth": {
"type": "service_http",
"authorization_type": "bearer",
"verification_tokens": {
"openai": "cb7cdfb8a57e45bc8ad7dea5bc2f8324"
}
},
Just like how a user might already be using your API, we allow user level authentication through enabling end users to copy and paste their secret API key into the ChatGPT UI during plugin install. While we encrypt the secret key when we store it in our database, we do not recommend this approach given the poor user experience.
就像用户可能已经在使用您的API一样,我们允许最终用户在插件安装期间将其API密钥复制并粘贴到ChatGPT UI中,从而实现用户级身份验证。虽然我们在将密钥存储在数据库中时会对其进行加密,但考虑到用户体验较差,我们不建议使用这种方法。
"auth": {
"type": "user_http",
"authorization_type": "bearer",
},
The plugin protocol is compatible with OAuth. A simple example of the OAuth flow we are expecting in the manifest looks like the following:
插件协议与OAuth兼容。我们在清单中期望的OAuth流的一个简单示例如下所示:
"auth": {
"type": "oauth",
"client_url": "https://my_server.com/authorize",
"scope": "",
"authorization_url": "https://my_server.com/token",
"authorization_content_type": "application/json",
"verification_tokens": {
"openai": "abc123456"
}
},
To better understand the URL structure for OAuth, here is a short description of the fields:
为了更好地理解OAuth的URL结构,下面是字段的简短说明:
client_id
and client_secret
client_id
和 client_secret
"[client_url]?response_type=code&client_id=[client_id]&scope=[scope]&redirect_uri=https%3A%2F%2Fchat.openai.com%2Faip%2F[plugin_id]%2Foauth%2Fcallback"
"[client_url]?response_type=code&client_id=[client_id]&scope=[scope]&redirect_uri=https%3A%2F%2Fchat.openai.com%2Faip%2F[plugin_id]%2Foauth%2Fcallback"
authorization_content_type
and parameters { “grant_type”: “authorization_code”, “client_id”: [client_id], “client_secret”: [client_secret], “code”: [the code that was returned with the redirect], “redirect_uri”: [the same redirect uri as before] }
authorization_content_type
和参数 { “grant_type”: “authorization_code”, “client_id”: [client_id], “client_secret”: [client_secret], “code”: [the code that was returned with the redirect], “redirect_uri”: [the same redirect uri as before] }
向 authorization_url
发出POST请求来完成OAuth流程如果大家想继续了解人工智能相关学习路线和知识体系,欢迎大家翻阅我的另外一篇博客《重磅 | 完备的人工智能AI 学习——基础知识学习路线,所有资料免关注免套路直接网盘下载》
这篇博客参考了Github知名开源平台,AI技术平台以及相关领域专家:Datawhale,ApacheCN,AI有道和黄海广博士等约有近100G相关资料,希望能帮助到所有小伙伴们。