From abbb94a5536af320fa1940cf34f6495825f27cae Mon Sep 17 00:00:00 2001 From: wuhang2003 <108316419+wuhang2003@users.noreply.github.com> Date: Sun, 8 Sep 2024 10:07:27 +0000 Subject: [PATCH 1/2] feat: add oauth --- components/Icons/UilKeySkeletonAlt.tsx | 7 ++++++ pages/themes/shiro/index.mdx | 17 +++++++++------ pages/usage/_meta.json | 1 + pages/usage/index.mdx | 7 ++++++ pages/usage/oauth.mdx | 30 ++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 components/Icons/UilKeySkeletonAlt.tsx create mode 100644 pages/usage/oauth.mdx diff --git a/components/Icons/UilKeySkeletonAlt.tsx b/components/Icons/UilKeySkeletonAlt.tsx new file mode 100644 index 00000000..eecdfe28 --- /dev/null +++ b/components/Icons/UilKeySkeletonAlt.tsx @@ -0,0 +1,7 @@ +import { SVGProps } from 'react' + +export function UilKeySkeletonAlt(props: SVGProps) { + return ( + + ) +} \ No newline at end of file diff --git a/pages/themes/shiro/index.mdx b/pages/themes/shiro/index.mdx index 83c4baf6..01912979 100644 --- a/pages/themes/shiro/index.mdx +++ b/pages/themes/shiro/index.mdx @@ -33,11 +33,14 @@ import { ToGitHub } from '@components/ToGitHub' - 你已安装 Mix Space 后端并且已启动 - (选择 Vercel 部署)已注册 [Vercel](https://vercel.com/) 和 [GitHub](https://github.com/) 账号 - + [「移除 Edge Config」](#移除-edge-config) 部分。~~ + ## 准备步骤 @@ -265,11 +268,11 @@ import { EnvVariableConfig } from '@components/EnvVariableConfig' }, { key: 'NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY', - name: 'Clerk 页面的公钥', + name: 'Clerk 页面的公钥(已过时)', }, { key: 'CLERK_SECRET_KEY', - name: 'Clerk 页面的私钥', + name: 'Clerk 页面的私钥(已过时)', }, { key: 'ENABLE_EXPERIMENTAL_COREPACK', @@ -311,7 +314,7 @@ import { EnvVariableConfig } from '@components/EnvVariableConfig' 参见 [README 相关部分](https://github.com/Innei/Shiro/blob/main/README.md#whale-运行) 完成对应操作,随后配置[反向代理](/docs/extra#反向代理)。 -## Clerk 登录与 Mix Space 后端绑定 +## Clerk 登录与 Mix Space 后端绑定(已过时) 如果你遇到在 Shiro 登录之后,无法评论遇到 "和主人重名" 的报错,是因为 Clerk 的用户名和 Mix Space 后端的用户名重复了,你需要绑定本系统和 Clerk 的用户。让某个 Clerk 用户具有管理员权限。 diff --git a/pages/usage/_meta.json b/pages/usage/_meta.json index dc4b35e8..983fa355 100644 --- a/pages/usage/_meta.json +++ b/pages/usage/_meta.json @@ -10,6 +10,7 @@ "backup": "备份与回滚", "update": "更新 Mix Space", "security": "Key 加密与安全性", + "oauth": "OAuth 2.0", "-- community": { "type": "separator", "title": "社区使用指南" diff --git a/pages/usage/index.mdx b/pages/usage/index.mdx index 00a73067..d53f1564 100644 --- a/pages/usage/index.mdx +++ b/pages/usage/index.mdx @@ -16,6 +16,7 @@ import { UilSearchAlt } from '@components/Icons/SearchAlt' import { UilBitcoin } from '@components/Icons/Bitcoin' import { UilHistoryAlt } from '@components/Icons/HistoryAlt' import { UilArrowCircleUp } from '@components/Icons/ArrowCircleUp' +import { UilKeySkeletonAlt } from '@components/Icons/UilKeySkeletonAlt' + } + arrow + href={'/usage/oauth'} + title="OAuth 2.0" + /> ### 社区使用指南 diff --git a/pages/usage/oauth.mdx b/pages/usage/oauth.mdx new file mode 100644 index 00000000..0085b9a0 --- /dev/null +++ b/pages/usage/oauth.mdx @@ -0,0 +1,30 @@ +# OAuth 2.0 + +import { Steps } from 'nextra/components'; + +在 Core v7.0.0 版本,Mx-Space 重写了第三方登录功能,抛弃了 Clerk,转而直接使用对应的账户授权 SDK 实现第三方登录。 + +## 如何配置 + + + +### 新建应用 + +参考以下两篇: + +- [在 GitHub 新建 OAuth 应用](https://docs.github.com/zh/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app) +- [在 Google Cloud 新建 OAuth 应用](https://developers.google.com/identity/protocols/oauth2/web-server?hl=zh-cn#creatingcred) + +其中 `Homepage URL` 填写前端地址,`Authorization callback URL` 根据后台提示复制粘贴。 + +完成后会获取 Client ID 和 Client Secret,将他们复制下来备用。 + +### 后台设置 + +进入博客后台 -> 设定 -> 登录方式,在 OAuth 部分对应的平台名称下填写对应的 Client ID 和 Client Secret,保存后测试是否可以调用授权,若可调用即可启用并保存。 + +### 和主人身份绑定 + +在测试时通过 OAuth 授权登录后会提示是否将此账号设置为主人,允许即可。 + + \ No newline at end of file From f913bf9ac3fb46f6b4f552b4b5bcc604ed948c71 Mon Sep 17 00:00:00 2001 From: wuhang2003 <108316419+wuhang2003@users.noreply.github.com> Date: Sun, 8 Sep 2024 10:24:20 +0000 Subject: [PATCH 2/2] fix: add content --- pages/usage/oauth.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pages/usage/oauth.mdx b/pages/usage/oauth.mdx index 0085b9a0..07f74718 100644 --- a/pages/usage/oauth.mdx +++ b/pages/usage/oauth.mdx @@ -15,7 +15,9 @@ import { Steps } from 'nextra/components'; - [在 GitHub 新建 OAuth 应用](https://docs.github.com/zh/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app) - [在 Google Cloud 新建 OAuth 应用](https://developers.google.com/identity/protocols/oauth2/web-server?hl=zh-cn#creatingcred) -其中 `Homepage URL` 填写前端地址,`Authorization callback URL` 根据后台提示复制粘贴。 +对于 GitHub,`Homepage URL` 填写前端地址,`Authorization callback URL` 根据后台提示复制粘贴。 + +对于 Google,`已获授权的 JavaScript 来源` 填写前端地址,`已获授权的重定向 URI` 根据后台提示复制粘贴。 完成后会获取 Client ID 和 Client Secret,将他们复制下来备用。