Apple
了解如何配置 LibreChat 以使用 Apple 进行用户身份验证。
先决条件
在开始之前,请确保您已具备以下条件:
- Apple Developer Account: 如果您还没有账号,请在此注册。
创建新的 App ID
1. 登录 Apple Developer Console
- 操作:
- 访问 Apple Developer 并使用您的 Apple ID 登录。
2. 导航至 Identifiers
- 前往 Certificates, Identifiers & Profiles。
- 点击侧边栏中的 Identifiers。
3. 创建一个新的 App ID
- 点击 "+" 按钮以添加新的标识符。
- 选择 App IDs 并点击 Continue。
- 选择 App 并点击 Continue。
- 为您的 App ID 输入一个 Description(例如
LibreChat App ID)。 - 设置 Bundle ID(例如
com.yourdomain.librechat)。 - 点击 Continue,然后点击 Register。
-
图像引用:
-
图 1:创建新的 App ID -
图 2:选择 App Identifier
4. 启用 "Sign in with Apple"
- 创建 App ID 后,点击它进行编辑。
- 在 Capabilities 下,找到并勾选 Sign in with Apple。
- 点击 Save。
- 图像参考:
图 3:启用“使用 Apple 登录”
创建 Services ID
1. 导航至 Identifiers
- 在 Certificates, Identifiers & Profiles 部分中,点击 Identifiers。
2. 创建一个新的 Services ID
- 点击 "+" 按钮。
- 选择 Services IDs 并点击 Continue。
- 输入一个 Description(例如
LibreChat Services ID)。 - 输入一个 Identifier(例如
com.yourdomain.librechat.services)。 - 点击 Continue,然后点击 Register。
-
图像引用:
-
图 4:选择 Services ID -
图 5:创建服务 ID
3. 配置 "Sign in with Apple"
- 点击新创建的 Services ID。
- 在 Capabilities 下,点击 Sign in with Apple 旁边的 Configure。
- 输入您的 Domains(例如
your-domain.com)和 Return URLs(例如https://your-domain.com/oauth/apple/callback)。 - 点击 Next,然后点击 Register。
-
图像参考:
-
图 6:为 Services ID 配置“使用 Apple 登录”
-
图 7:Web 身份验证配置
-
图 8:保存编辑服务 ID 配置
创建密钥
1. 导航至 Keys
- 在 Certificates, Identifiers & Profiles 部分中,点击 Keys。
2. 创建新密钥
- 点击 "+" 按钮以添加新密钥。
- 输入一个 Key Name(例如
LibreChatSignInWithApple)。 - 在 Capabilities 下选择 Sign in with Apple。
- 点击 Configure 并选择已创建的 App ID(例如
com.yourdomain.librechat),然后点击 Save。 - 点击 Continue,然后点击 Register。
-
图像引用:
-
图 8:创建新密钥
-
图 9:配置带有 App ID 的 Key
-
图 10:注册密钥
3. 下载私钥
- 创建密钥后,点击 Download。
- 重要提示: 请妥善保存
.p8文件。您将无法再次下载该文件。 - 请注意 Key ID;你需要在
.env文件中使用它。
- 图像参考:
图 11:下载私钥
配置 LibreChat
1. 更新 .env 配置
将以下 Apple OAuth2 配置添加到您的 .env 文件中:
注意:
- 将
com.yourdomain.librechat.services替换为您实际的 Services ID。- 将
YOUR_TEAM_ID和YOUR_KEY_ID替换为您 Apple Developer 账户中的相应值。- 如果使用 Docker,请确保
.p8文件在 Docker 容器内可访问,并相应地更新APPLE_PRIVATE_KEY_PATH。
2. 重启 LibreChat
更新 .env 文件后,请重启 LibreChat 以应用更改。
- 如果使用 Docker:
故障排除
如果在设置过程中遇到问题,请考虑以下解决方案:
-
无效的重定向 URI:
- 请确保您在 Apple Developer Console 中设置的重定向 URI (
https://your-domain.com/oauth/apple/callback) 与您.env文件中指定的 URI (APPLE_CALLBACK_URL) 完全一致。
- 请确保您在 Apple Developer Console 中设置的重定向 URI (
-
私钥问题:
- 请验证您的
.p8文件路径 (APPLE_PRIVATE_KEY_PATH) 是否正确。 - 确保 LibreChat 对
.p8文件拥有读取权限。
- 请验证您的
-
团队 ID 和密钥 ID 错误:
- 请仔细核对
.env文件中的APPLE_TEAM_ID和APPLE_KEY_ID是否与您的 Apple Developer Account 中的信息一致。
- 请仔细核对
-
域名验证失败:
- 确保验证文件已正确上传到您域名的根目录。
- 请核实配置过程中输入的域名是否存在拼写错误。
-
Docker 配置问题:
- 如果使用 Docker,请确认
.p8文件已正确挂载,并且APPLE_PRIVATE_KEY_PATH中的路径在容器内可访问。
- 如果使用 Docker,请确认
-
检查日志:
- 检查 LibreChat 日志中是否有与 Apple 身份验证相关的任何错误消息。这可以提供关于可能出现问题的具体见解。
这篇指南怎么样?