-
-
Notifications
You must be signed in to change notification settings - Fork 12k
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
✨feat: Support database session & token refresh for sso providers #6209
base: main
Are you sure you want to change the base?
Conversation
@cy948 is attempting to deploy a commit to the LobeHub Team on Vercel. A member of the Team first needs to authorize it. |
👍 @cy948 Thank you for raising your pull request and contributing to our Community |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6209 +/- ##
==========================================
+ Coverage 91.53% 97.57% +6.04%
==========================================
Files 689 14 -675
Lines 63110 3670 -59440
Branches 2951 203 -2748
==========================================
- Hits 57767 3581 -54186
+ Misses 5343 89 -5254
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
02179a0
to
50896f0
Compare
f1646dd
to
689c22e
Compare
bb202f7
to
fe8bbb1
Compare
fe8bbb1
to
4cf2829
Compare
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
📝 补充信息 | Additional Information
背景
在之前的NextAuth接入中,仅使用Auth服务进行单次授权。即当Auth服务“允许”用户访问Lobe应用后,剩下的时间用户是否有效均由Lobe控制。这种做法:
而现状是,Lobe社区版尚未支持对用户的控制等管理功能,无法对用户进行管理。针对以上问题,提出一种能满足Lobe及Auth服务对用户进行管理的方案:
Token Rotation
):在Lobe中,在Auth服务授权的访问令牌(access_token)进行刷新,以获取当前用户在 Auth 服务的授权状态:正常、禁用:Webhook
,database session
):Auth服务会在“禁用”用户时,通过webhook向lobe发送事件,Lobe可在收到事件后,清除目标用户的会话,强制用户重新登录。Token Rotation | 访问令牌刷新
RFC6749 中允许已授权流程的应用(
[A]->[F]
)使用refresh_token
向授权中心刷新access_token
[G] -> [H]
。依据 AuthJS 文档建议的实现,在用户请求 session 时,前往 Auth 服务刷新令牌,使 Lobe 用户的登录状态受到 Auth 服务约束,实现以下功能:
Database Session | 数据库会话管理支持
将会话管理设为由数据库集中管理,以便在 Auth 服务禁用用户时,用户将立即被禁止使用 Lobe。
Webhook
处理 Auth 服务对用户进行禁用、强制登出的事件。
功能支持列表
#6094