Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feishu auth provider #6386

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

sssession
Copy link

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • 📝 docs
  • 🔨 chore

🔀 变更说明 | Description of Change

增加飞书 oAuth 登录

📝 补充信息 | Additional Information

Copy link

vercel bot commented Feb 21, 2025

Someone is attempting to deploy a commit to the LobeChat Desktop Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 21, 2025
@lobehubbot
Copy link
Member

👍 @sssession

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

@dosubot dosubot bot added the 🌠 Feature Request New feature or request | 特性与建议 label Feb 21, 2025
@arvinxx
Copy link
Contributor

arvinxx commented Feb 21, 2025

请给出流程demo 演示哈,可以是录屏

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Please give a demo process, it can be a screen recording

@sssession
Copy link
Author

请给出流程demo 演示哈,可以是录屏

20250221143449.webm

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Please give a demo process, it can be a screen recording

20250221143449.webm

@cy948
Copy link
Contributor

cy948 commented Feb 21, 2025

接入文档需要补一下

  • /docs/self-hosting/advanced/auth
  • /docs/self-hosting/advanced/auth/next-auth/[provider]

@@ -269,6 +277,10 @@ export const getAuthConfig = () => {

// Casdoor
CASDOOR_WEBHOOK_SECRET: process.env.CASDOOR_WEBHOOK_SECRET,

// feishu
FEISHU_APP_ID: process.env.FEISHU_APP_ID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clientId 和 secret 的环境变量命名对齐一下 environment variable inference 。 https://authjs.dev/getting-started/deployment

@hedeqiang
Copy link
Contributor

飞书 和 Lark 同理吗?日常在用 Lark 办公,命名上是不是可以考虑 下 Lark

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Are Feishu and Lark the same? When using Lark for daily use, can you consider Lark?

@sssession
Copy link
Author

飞书 和 Lark 同理吗?日常在用 Lark 办公,命名上是不是可以考虑 下 Lark

有什么建议吗?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Are Feishu and Lark the same? When using Lark for daily use, can you consider Lark?

Any suggestions?

@hedeqiang
Copy link
Contributor

飞书 和 Lark 同理吗?日常在用 Lark 办公,命名上是不是可以考虑 下 Lark

有什么建议吗?

看大佬们的吧,可以忽略我,感觉 lark 和飞书 应该只是请求URL 上的区别

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Are Feishu and Lark the same? When using Lark for daily use, can you consider Lark?

Any suggestions?

Look at the big guys, you can ignore me. I feel that the difference between lark and Feishu should be just the request URL

@sssession
Copy link
Author

飞书 和 Lark 同理吗?日常在用 Lark 办公,命名上是不是可以考虑 下 Lark

有什么建议吗?

看大佬们的吧,可以忽略我,感觉 lark 和飞书 应该只是请求URL 上的区别

他们本身是标准的 oAuth 协议,这个 pr 也只是增加了一些 auth.js 配置,混在一起可能还更容易引起歧义。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Are Feishu and Lark the same? When using Lark for daily use, can you consider Lark?

Any suggestions?

Look at the big guys, you can ignore me, I feel that the difference between lark and Feishu should be just the request URL

They themselves are the standard oAuth protocol, and this pr only adds some auth.js configuration, which may be more likely to cause ambiguity when mixed together.

@cy948
Copy link
Contributor

cy948 commented Feb 24, 2025

可以试试里面的generic oidc provider能不能兼容,那是标准的实现。

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


You can try whether the generic oidc provider is compatible, which is a standard implementation.

@sssession
Copy link
Author

可以试试里面的generic oidc provider能不能兼容,那是标准的实现。

官方没有文档说明支持 oidc,实际测试发现飞书不支持(不支持 well-know 协议

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


You can try whether the generic oidc provider in it can be compatible, that is a standard implementation.

There is no official documentation to support oidc. In actual testing, it was found that Feishu does not support it (it does not support the well-know protocol.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Feb 25, 2025

## feishu

### `FEISHU_APP_ID`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文档的变量名对齐一下 authjs 的规范呗

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文档正在补齐。我把 PR 标记为 draft 了。

provider: Feishu(),
};

export default provider;
Copy link
Contributor

@cy948 cy948 Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参照 https://github.com/lobehub/lobe-chat/blob/main/src/libs/next-auth/sso-providers/logto.ts 的实现,把代码重构一下,先写基础的 Provider,最后在 function 入参的地方通过环境变量传入 app id, secret 等。 环境变量只需要 process.env.AUTH_[provider id ]_ID 这个,前面的就不需要加了,前面的写法在 2.0 会废弃的。

provider: LobeLogtoProvider({
authorization: {
params: { scope: 'openid offline_access profile email' },
},
// You can get the issuer value from the Logto Application Details page,
// in the field "Issuer endpoint"
clientId: authEnv.LOGTO_CLIENT_ID ?? process.env.AUTH_LOGTO_ID,
clientSecret: authEnv.LOGTO_CLIENT_SECRET ?? process.env.AUTH_LOGTO_SECRET,
issuer: authEnv.LOGTO_ISSUER ?? process.env.AUTH_LOGTO_ISSUER,
}),
};

Copy link
Author

@sssession sssession Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.env.AUTH_[provider id ]_ID 环境变量会被 auth.js 自动读取。还需要显示传入吗? @cy948

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把scope和profile处理函数显式声明一下

@sssession sssession marked this pull request as draft February 26, 2025 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌠 Feature Request New feature or request | 特性与建议 size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants