-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 📝 docs: Logto & fix typo. * 📝 docs: Logto variables & fix typo.
- Loading branch information
1 parent
c53fee6
commit 64eb7c2
Showing
10 changed files
with
274 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
title: Configuring Logto Authentication Service in LobeChat | ||
description: >- | ||
Learn how to configure Logto authentication service in LobeChat, including | ||
deployment, creation, setting permissions, and environment variables. | ||
tags: | ||
- Logto Authentication | ||
- Environment Variable Configuration | ||
- Single Sign-On | ||
- LobeChat | ||
--- | ||
|
||
# Configuring Logto Authentication Service | ||
|
||
[Logto](https://github.com/logto-io/logto) is an open-source authentication service with a simple and beautiful interface, rich in features and easy to use. You can choose to use the official Logto Cloud or opt for a private deployment of Logto. | ||
|
||
<Callout type={'tip'}> | ||
|
||
If you want to deploy Logto privately, we recommend using Docker Compose to deploy it together with the LobeChat database version. In this case, LobeChat can share the same Postgres instance with it. | ||
|
||
</Callout> | ||
|
||
## Logto Configuration Process | ||
|
||
The following assumes your LobeChat database version domain is `https://lobe.example.com`. | ||
|
||
If you are using a privately deployed Logto, assume its endpoint domain is `https://lobe-auth-api.example.com`. | ||
|
||
If you are using Logto Cloud, assume its endpoint domain is `https://example.logto.app`. | ||
|
||
<Steps> | ||
### Create Logto Application | ||
|
||
Access your privately deployed Logto WebUI or [Logto Cloud](http://cloud.logto.io/) to enter the console, and create a `Next.js (App Router)` application under `Applications` with any name. | ||
|
||
### Configure Logto | ||
|
||
Set the `Redirect URI` to `https://lobe.example.com/api/auth/callback/logto` and the `Post sign-out redirect URI` to `https://lobe.example.com/`. | ||
|
||
Set `CORS allowed origins` to `https://lobe.example.com`. | ||
|
||
<Image alt="Configure Logto" inStep src="https://github.com/user-attachments/assets/5b816379-c07b-40ea-bde4-df16e2e4e523" /> | ||
|
||
After successful creation, save the `Client ID` and `Client Secret`. | ||
|
||
### Configure Environment Variables | ||
|
||
<Image alt="Configure Environment Variables" inStep src="https://github.com/user-attachments/assets/15af6d94-af4f-4aa9-bbab-7a46e9f9e837" /> | ||
|
||
Set the obtained `Client ID` and `Client Secret` as `LOGTO_CLIENT_ID` and `LOGTO_CLIENT_SECRET` in the LobeChat environment variables. | ||
|
||
Configure `LOGTO_ISSUER` in the LobeChat environment variables as follows: | ||
|
||
- `https://lobe-auth-api.example.com/oidc` if you are using a privately deployed Logto | ||
- `https://example.logto.app/oidc` if you are using Logto Cloud | ||
|
||
When deploying LobeChat, you need to configure the following environment variables: | ||
|
||
| Environment Variable | Type | Description | | ||
| ------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `NEXT_AUTH_SECRET` | Required | The key used to encrypt Auth.js session tokens. You can generate a key using the command: `openssl rand -base64 32` | | ||
| `NEXT_AUTH_SSO_PROVIDERS` | Required | Select the single sign-on provider for LobeChat. For Logto, enter `logto`. | | ||
| `LOGTO_CLIENT_ID` | Required | The Client ID from the Logto App details page | | ||
| `LOGTO_CLIENT_SECRET` | Required | The Client Secret from the Logto App details page | | ||
| `LOGTO_ISSUER` | Required | OpenID Connect issuer of the Logto provider | | ||
| `NEXTAUTH_URL` | Optional | This URL specifies the callback address for Auth.js during OAuth verification, needed only if the default generated redirect address is incorrect. `https://lobe.example.com/api/auth` | | ||
|
||
<Callout type={'tip'}> | ||
Visit [📘 Environment Variables](/docs/self-hosting/environment-variables/auth#logto) for details on related variables. | ||
|
||
</Callout> | ||
</Steps> | ||
|
||
<Callout type={'info'}>After successful deployment, users will be able to authenticate via Logto and use LobeChat.</Callout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
title: 在 LobeChat 中配置 Logto 身份验证服务 | ||
description: 学习如何在 LobeChat 中配置 Logto 身份验证服务,包括部署、创建、设置权限和环境变量。 | ||
tags: | ||
- Logto 身份验证 | ||
- 环境变量配置 | ||
- 单点登录 | ||
- LobeChat | ||
--- | ||
|
||
# 配置 Logto 身份验证服务 | ||
|
||
[Logto](https://github.com/logto-io/logto) 是一个开源的身份验证服务,界面简洁美观、功能配置丰富且易于上手,你即可以选择使用其官方提供的 Logto Cloud,也可以选择私有部署 Logto。 | ||
|
||
<Callout type={'tip'}> | ||
若你想要私有部署 Logto,我们建议你将之与 LobeChat 数据库版本一同使用 Docker Compose 部署,此时 LobeChat 可以与之共用同一个 Postgres 实例。 | ||
</Callout> | ||
|
||
## Logto 配置流程 | ||
|
||
下文假设你的 LobeChat 数据库版本域名为 `https://lobe.example.com`。 | ||
|
||
若你是私有部署的 Logto,假设其 endpoint 域名为 `https://lobe-auth-api.example.com`。 | ||
|
||
若你是使用的 Logto Cloud,假设其 endpoint 域名为 `https://example.logto.app`。 | ||
|
||
<Steps> | ||
### 创建 Logto 应用 | ||
|
||
访问你私有部署的 Logto WebUI 或者 [Logto Cloud](http://cloud.logto.io/) 进入控制台,在 `Applications` 里创建一个 `Next.js (App Router)` 应用,名称随意 | ||
|
||
### 配置 Logto | ||
|
||
配置 `Redirect URI` 为 `https://lobe.example.com/api/auth/callback/logto`,`Post sign-out redirect URI` 为 `https://lobe.example.com/` | ||
|
||
配置 `CORS allowed origins` 为 `https://lobe.example.com` | ||
|
||
<Image | ||
alt="配置 Logto" | ||
inStep | ||
src="https://github.com/user-attachments/assets/5b816379-c07b-40ea-bde4-df16e2e4e523" | ||
/> | ||
|
||
创建成功后, 将 `Client ID` 和 `Client Secret` 保存下来。 | ||
|
||
### 配置环境变量 | ||
|
||
<Image | ||
alt="配置环境变量" | ||
inStep | ||
src="https://github.com/user-attachments/assets/15af6d94-af4f-4aa9-bbab-7a46e9f9e837" | ||
/> | ||
|
||
将获取到的 `Client ID` 和 `Client Secret`,设为 LobeChat 环境变量中的 `LOGTO_CLIENT_ID` 和 `LOGTO_CLIENT_SECRETT`。 | ||
|
||
配置 LobeChat 环境变量中 `LOGTO_ISSUER` 为: | ||
|
||
- `https://lobe-auth-api.example.com/oidc`,若你是私有部署的 Logto | ||
- `https://example.logto.app/oidc`,若你是使用的 Logto Cloud | ||
|
||
在部署 LobeChat 时,你需要配置以下环境变量: | ||
|
||
| 环境变量 | 类型 | 描述 | | ||
| --- | --- | --- | | ||
| `NEXT_AUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32` | | ||
| `NEXT_AUTH_SSO_PROVIDERS` | 必选 | 选择 LoboChat 的单点登录提供商。使用 Logto 请填写 `logto`。 | | ||
| `LOGTO_CLIENT_ID` | 必选 | Logto App 详情页的 Client ID | | ||
| `LOGTO_CLIENT_SECRET` | 必选 | Logto App 详情页的 Client Secret | | ||
| `LOGTO_ISSUER` | 必选 | Logto 提供程序的 OpenID Connect 颁发者 | | ||
| `NEXTAUTH_URL` | 可选 | 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://lobe.example.com/api/auth` | | ||
|
||
<Callout type={'tip'}> | ||
前往 [📘 环境变量](/docs/self-hosting/environment-variables/auth#logto) 可查阅相关变量详情。 | ||
|
||
</Callout> | ||
</Steps> | ||
|
||
<Callout type={'info'}>部署成功后,用户将可以通过 Logto 身份认证并使用 LobeChat。</Callout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.