Skip to content

Commit bf8ef1f

Browse files
authored
✨ feat: support clerk as auth provider (#2374)
* ✨ feat: support clerk as auth provider * ♻️ refactor: refactor the auth env config to `s3-oss/env` * ✅ test: add test for the theme mode and action * 💄 style: fix style * 🌐 chore: update locale * ✅ test: add more test * 🎨 chore: clean code * 📝 docs: update docs
1 parent 06a1d97 commit bf8ef1f

File tree

136 files changed

+15860
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+15860
-383
lines changed

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ public-hoist-pattern[]=*semantic-release*
1414
public-hoist-pattern[]=*stylelint*
1515

1616
public-hoist-pattern[]=@auth/core
17+
public-hoist-pattern[]=@clerk/backend
18+
public-hoist-pattern[]=@clerk/types

docs/self-hosting/advanced/authentication.mdx

+25-18
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
11
---
2-
title: >-
3-
LobeChat Identity Verification Service - Centralized User Authorization
4-
Management
2+
title: LobeChat Authorization Service
53
description: >-
64
Learn about LobeChat's support for configuring external identity verification
75
services for centralized user authorization within enterprises/organizations.
86
Explore supported services like Auth0, Microsoft Entra ID, Authentik, Github,
97
and ZITADEL.
108
tags:
11-
- Identity Verification Service
12-
- Centralized User Authorization
139
- SSO Providers
14-
- Auth0
15-
- Microsoft Entra ID
16-
- Authentik
17-
- Github
18-
- ZITADEL
10+
- Next Auth
11+
- Clerk
1912
---
2013

21-
# Identity Verification Service
14+
# LobeChat Authorization
2215

2316
LobeChat supports the configuration of external identity verification services for internal use within enterprises/organizations to centrally manage user authorization.
2417

25-
Currently supported identity verification services include:
18+
## Clerk
19+
20+
Clerk is a comprehensive identity verification solution that has recently gained popularity. It provides a simple yet powerful API and services to handle user authentication and session management. Clerk's design philosophy is to offer a concise and modern authentication solution that enables developers to easily integrate and use it.
21+
22+
LobeChat has deeply integrated with Clerk to provide users with a more secure and convenient login and registration experience. It also relieves developers from the burden of managing authentication logic. Clerk's concise and modern design philosophy aligns perfectly with LobeChat's goals, making user management on the entire platform more efficient and reliable.
2623

27-
- [Auth0](/docs/self-hosting/advanced/sso-providers/auth0)
28-
- [Microsoft Entra ID](/docs/self-hosting/advanced/sso-providers/microsoft-entra-id)
29-
- [Authentik](/docs/self-hosting/advanced/sso-providers/authentik)
30-
- [Github](/docs/self-hosting/advanced/sso-providers/github)
31-
- [ZITADEL](/docs/self-hosting/advanced/sso-providers/zitadel)
24+
By setting the environment variables NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY in LobeChat's environment, you can enable and use Clerk.
25+
26+
## Next Auth
27+
28+
Currently supported identity verification services include:
3229

30+
<Cards>
31+
<Card href={'/docs/self-hosting/advanced/sso-providers/auth0'} title={'Auth0'} />
32+
<Card
33+
href={'/docs/self-hosting/advanced/sso-providers/microsoft-entra-id'}
34+
title={'Microsoft Entra ID'}
35+
/>
36+
<Card href={'/docs/self-hosting/advanced/sso-providers/authentik'} title={'Authentik'} />
37+
<Card href={'/docs/self-hosting/advanced/sso-providers/github'} title={'Github'} />
38+
<Card href={'/docs/self-hosting/advanced/sso-providers/zitadel'} title={'ZITADEL'} />
39+
</Cards>
3340
Click on the links to view the corresponding platform's configuration documentation.
3441

3542
## Advanced Configuration
3643

37-
To simultaneously enable multiple identity verification sources, please set the `SSO_PROVIDERS` environment variable, separating them with commas, for example, `auth0,azure-ad,authentik`.
44+
To simultaneously enable multiple identity verification sources, please set the `NEXT_AUTH_SSO_PROVIDERS` environment variable, separating them with commas, for example, `auth0,azure-ad,authentik`.
3845

3946
The order corresponds to the display order of the SSO providers.
4047

docs/self-hosting/advanced/authentication.zh-CN.mdx

+26-17
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
11
---
2-
title: LobeChat 外部身份验证服务配置指南
3-
description: >-
4-
了解如何配置外部身份验证服务以统一管理用户授权。支持的身份验证服务包括 Auth0, Microsoft Entra ID, Authentik,
5-
Github, 和 ZITADEL。
2+
title: LobeChat 身份验证服务配置
3+
description: 了解如何使用 Clerk 或 Next Auth 配置外部身份验证服务,以统一管理用户授权。支持的身份验证服务包括 Auth0、 Azure ID 等。
64
tags:
75
- 身份验证服务
86
- LobeChat
97
- SSO
10-
- Auth0
11-
- Microsoft Entra ID
12-
- Authentik
13-
- Github
14-
- ZITADEL
8+
- Clerk
159
---
1610

1711
# 身份验证服务
1812

19-
LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用,统一管理用户授权。
13+
LobeChat 支持使用 Clerk 或者 Next Auth 配置外部身份验证服务,供企业 / 组织内部使用,统一管理用户授权。
14+
15+
## Clerk
16+
17+
Clerk 是一个近期流行起来的全面的身份验证解决方案,它提供了简单而强大的 API 和服务来处理用户认证和会话管理。Clerk 的设计哲学是提供一套简洁、现代的认证解决方案,使得开发者可以轻松集成和使用。
18+
19+
LobeChat 与 Clerk 做了深度集成,能够为用户提供一个更加安全、便捷的登录和注册体验,同时也为开发者减轻了管理身份验证逻辑的负担。Clerk 的简洁和现代的设计理念与 LobeChat 的目标非常契合,使得整个平台的用户管理更加高效和可靠。
20+
21+
在 LobeChat 的环境变量中设置 `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY``CLERK_SECRET_KEY`,即可开启和使用 Clerk。
22+
23+
## Next Auth
2024

2125
目前支持的身份验证服务有:
2226

23-
- [Auth0](/docs/self-hosting/advanced/sso-providers/auth0)
24-
- [Microsoft Entra ID](/docs/self-hosting/advanced/sso-providers/microsoft-entra-id)
25-
- [Authentik](/docs/self-hosting/advanced/sso-providers/authentik)
26-
- [Github](/docs/self-hosting/advanced/sso-providers/github)
27-
- [ZITADEL](/docs/self-hosting/advanced/sso-providers/zitadel)
27+
<Cards>
28+
<Card href={'/zh/docs/self-hosting/advanced/sso-providers/auth0'} title={'Auth0'} />
29+
<Card
30+
href={'/zh/docs/self-hosting/advanced/sso-providers/microsoft-entra-id'}
31+
title={'Microsoft Entra ID'}
32+
/>
33+
<Card href={'/zh/docs/self-hosting/advanced/sso-providers/authentik'} title={'Authentik'} />
34+
<Card href={'/zh/docs/self-hosting/advanced/sso-providers/github'} title={'Github'} />
35+
<Card href={'/zh/docs/self-hosting/advanced/sso-providers/zitadel'} title={'ZITADEL'} />
36+
</Cards>
2837

29-
点击链接可以查看对应平台的配置文档
38+
点击即可查看对应平台的配置文档
3039

3140
## 进阶配置
3241

33-
同时启用多个身份验证源请设置 `SSO_PROVIDERS` 环境变量,以逗号 `,` 分割,例如 `auth0,azure-ad,authentik`
42+
同时启用多个身份验证源请设置 `NEXT_AUTH_SSO_PROVIDERS` 环境变量,以逗号 `,` 分割,例如 `auth0,azure-ad,authentik`
3443

3544
顺序为 SSO 提供商的显示顺序。
3645

docs/self-hosting/advanced/model-list.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ tags:
1414

1515
LobeChat supports customizing the model list during deployment. You can use `+` to add a model, `-` to hide a model, and use `model name=display name<extension configuration>` to customize the display name of a model, separated by English commas. The basic syntax is as follows:
1616

17-
```shell
18-
id=displayName < maxToken:vision:fc:file > ,model2,model3
17+
```text
18+
id=displayName<maxToken:vision:fc:file>,model2,model3
1919
```
2020

2121
For example: `+qwen-7b-chat,+glm-6b,-gpt-3.5-turbo,gpt-4-0125-preview=gpt-4-turbo`

docs/self-hosting/advanced/model-list.zh-CN.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ tags:
1212

1313
LobeChat 支持在部署时自定义模型列表,可以使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名<扩展配置>` 来自定义模型的展示名,用英文逗号隔开。通过 `<>` 来添加扩展配置。基本语法如下:
1414

15-
```shell
16-
id=displayName < maxToken:vision:fc:file > ,model2,model3
15+
```text
16+
id=displayName<maxToken:vision:fc:file>,model2,model3
1717
```
1818

1919
例如: `+qwen-7b-chat,+glm-6b,-gpt-3.5-turbo,gpt-4-0125-preview=gpt-4-turbo`

docs/self-hosting/environment-variables/auth.mdx

+48-39
Original file line numberDiff line numberDiff line change
@@ -5,150 +5,143 @@ description: >-
55
services in LobeChat, including OAuth SSO, NextAuth settings, and
66
provider-specific details.
77
tags:
8-
- LobeChat
98
- Authentication Service
10-
- Environment Variables
119
- OAuth SSO
10+
- Clerk
1211
- NextAuth
13-
- Provider Details
1412
---
1513

16-
## Authentication Service
14+
# Authentication Service
1715

1816
LobeChat provides a complete authentication service capability when deployed. The following are the relevant environment variables. You can use these environment variables to easily define the identity verification services that need to be enabled in LobeChat.
1917

20-
## General Settings
18+
## Next Auth
2119

22-
### `ENABLE_OAUTH_SSO`
20+
### General Settings
2321

24-
- Type: Required
25-
- Description: Enable single sign-on (SSO) for LobeChat. Set to `1` to enable single sign-on.
26-
- Default: `-`
27-
- Example: `1`
28-
29-
### `SSO_PROVIDERS`
30-
31-
- Type: Required
32-
- Description: Select the single sign-on provider for LoboChat. For multiple SSO Providers separating them with commas, for example, `auth0,azure-ad,authentik`.
33-
- Default: `auth0`
34-
- Example: `auth0,azure-ad,authentik`
35-
36-
### `NEXTAUTH_SECRET`
22+
#### `NEXTAUTH_SECRET`
3723

3824
- Type: Required
3925
- Description: Key used to encrypt the session tokens in Auth.js. You can generate the key using the following command: `openssl rand -base64 32`.
4026
- Default: `-`
4127
- Example: `Tfhi2t2pelSMEA8eaV61KaqPNEndFFdMIxDaJnS1CUI=`
4228

43-
### `NEXTAUTH_URL`
29+
#### `NEXTAUTH_URL`
4430

4531
- Type: Optional
4632
- Description: This URL is used to specify the callback address for Auth.js during OAuth authentication. It does not need to be set when deploying on Vercel.
4733
- Default: `-`
4834
- Example: `https://example.com/api/auth`
4935

50-
## Auth0
36+
#### `NEXT_AUTH_SSO_PROVIDERS`
37+
38+
- Type: Optional
39+
- Description: Select the single sign-on provider for LoboChat. For multiple SSO Providers separating them with commas, for example, `auth0,azure-ad,authentik`.
40+
- Default: `auth0`
41+
- Example: `auth0,azure-ad,authentik`
42+
43+
### Auth0
5144

52-
### `AUTH0_CLIENT_ID`
45+
#### `AUTH0_CLIENT_ID`
5346

5447
- Type: Required
5548
- Description: Client ID of the Auth0 application. You can access it [here](https://manage.auth0.com/dashboard) and navigate to the application settings to view.
5649
- Default: `-`
5750
- Example: `evCnOJP1UX8FMnXR9Xkj5t0NyFn5p70P`
5851

59-
### `AUTH0_CLIENT_SECRET`
52+
#### `AUTH0_CLIENT_SECRET`
6053

6154
- Type: Required
6255
- Description: Client Secret of the Auth0 application.
6356
- Default: `-`
6457
- Example: `wnX7UbZg85ZUzF6ioxPLnJVEQa1Elbs7aqBUSF16xleBS5AdkVfASS49-fQIC8Rm`
6558

66-
### `AUTH0_ISSUER`
59+
#### `AUTH0_ISSUER`
6760

6861
- Type: Required
6962
- Description: Issuer/domain of the Auth0 application.
7063
- Default: `-`
7164
- Example: `https://example.auth0.com`
7265

73-
## Microsoft Entra ID
66+
### Microsoft Entra ID
7467

75-
### `AZURE_AD_CLIENT_ID`
68+
#### `AZURE_AD_CLIENT_ID`
7669

7770
- Type: Required
7871
- Description: Client ID of the Microsoft Entra ID application.
7972
- Default: `-`
8073
- Example: `be8f6da1-58c3-4f16-ff1b-78f5148e10df`
8174

82-
### `AZURE_AD_CLIENT_SECRET`
75+
#### `AZURE_AD_CLIENT_SECRET`
8376

8477
- Type: Required
8578
- Description: Client Secret of the Microsoft Entra ID application.
8679
- Default: `-`
8780
- Example: `~gI8Q.pTiN1vwB6Gl.E1yFT1ojcXABkdACfJXaNj`
8881

89-
### `AZURE_AD_TENANT_ID`
82+
#### `AZURE_AD_TENANT_ID`
9083

9184
- Type: Required
9285
- Description: Tenant ID of the Microsoft Entra ID application.
9386
- Default: `-`
9487
- Example: `c8ae2f36-edf6-4cda-96b9-d3e198a47cba`
9588

96-
## Authentik
89+
### Authentik
9790

98-
### `AUTHENTIK_CLIENT_ID`
91+
#### `AUTHENTIK_CLIENT_ID`
9992

10093
- Type: Required
10194
- Description: Client ID of the Authentik provider application. You can access it [here][auth0-client-page] and navigate to the application settings to view.
10295
- Default: `-`
10396
- Example: `evCnOJP1UX8FMnXR9Xkj5t0NyFn5p70P`
10497

105-
### `AUTHENTIK_CLIENT_SECRET`
98+
#### `AUTHENTIK_CLIENT_SECRET`
10699

107100
- Type: Required
108101
- Description: Client Secret of the Authentik provider application.
109102
- Default: `-`
110103
- Example: `wnX7UbZg85ZUzF6ioxPLnJVEQa1Elbs7aqBUSF16xleBS5AdkVfASS49-fQIC8Rm`
111104

112-
### `AUTHENTIK_ISSUER`
105+
#### `AUTHENTIK_ISSUER`
113106

114107
- Type: Required
115108
- Description: Issuer/domain of the Authentik provider application.
116109
- Default: `-`
117110
- Example: `https://your-authentik-domain.com/application/o/slug/`
118111

119-
## Github
112+
### Github
120113

121-
### `GITHUB_CLIENT_ID`
114+
#### `GITHUB_CLIENT_ID`
122115

123116
- Type: Required
124117
- Description: Client ID of the Github application. You can access it [here](https://github.com/settings/apps) and navigate to the application settings to view.
125118
- Default: `-`
126119
- Example: `abd94200333283550508`
127120

128-
### `GITHUB_CLIENT_SECRET`
121+
#### `GITHUB_CLIENT_SECRET`
129122

130123
- Type: Required
131124
- Description: Client Secret of the Github application.
132125
- Default: `-`
133126
- Example: `dd262976ac0931d947e104891586a053f3d3750b`
134127

135-
## ZITADEL
128+
### ZITADEL
136129

137-
### `ZITADEL_CLIENT_ID`
130+
#### `ZITADEL_CLIENT_ID`
138131

139132
- Type: Required
140133
- Description: Client ID of the ZITADEL application. This can be found under your application in the ZITADEL console.
141134
- Default: `-`
142135
- Example: `123456789012345678@your-project`
143136

144-
### `ZITADEL_CLIENT_SECRET`
137+
#### `ZITADEL_CLIENT_SECRET`
145138

146139
- Type: Required
147140
- Description: Client Secret of the ZITADEL application.
148141
- Default: `-`
149142
- Example: `9QF1n5ATzU7Z3mHp2Iw4gKX8kY6oR7uW1DnKcV3LqX2jF6iG3fBmJ1kV7nS5zE6A`
150143

151-
### `ZITADEL_ISSUER`
144+
#### `ZITADEL_ISSUER`
152145

153146
- Type: Required
154147
- Description: Issuer of the ZITADEL application. This is usually the URL of the ZITADEL instance, and can be found in `URLs` tab of your application in the console.
@@ -160,3 +153,19 @@ LobeChat provides a complete authentication service capability when deployed. Th
160153
providers, you can submit a [feature
161154
request](https://github.com/lobehub/lobe-chat/issues/new/choose) or Pull Request.
162155
</Callout>
156+
157+
## Clerk
158+
159+
### `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`
160+
161+
- Type: Required
162+
- Description: Publishable key of the Clerk application. You can access it [here](https://dashboard.clerk.com) and navigate to the API Keys to view.
163+
- Default: `-`
164+
- Example: `pk_test_Zmxvd4luZy1wdW1hLTIyLmNsXXJrTmFjY291bnRzLmRldiQ` in dev / `pk_live_Y2xlcdsubG9iZWh1Yi1cbmMuY24k` in production
165+
166+
### `CLERK_SECRET_KEY`
167+
168+
- Type: Required
169+
- Description: Secret key of the Clerk application.
170+
- Default: `-`
171+
- Example: `sk_test_513Ma0P7IAWM1XMv4waxZjRYRajWTaCfJLjpEO3SD2` in dev / `sk_live_eMMlHjwJvZFUfczFljSKqZdwQtLvmczmsJSNmdrpeZ` in production

0 commit comments

Comments
 (0)