ai-engineering-init 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/code-reviewer.md +139 -0
- package/.claude/agents/project-manager.md +159 -0
- package/.claude/audio/completed.wav +0 -0
- package/.claude/commands/add-todo.md +255 -0
- package/.claude/commands/check.md +210 -0
- package/.claude/commands/crud.md +454 -0
- package/.claude/commands/dev.md +503 -0
- package/.claude/commands/init-docs.md +681 -0
- package/.claude/commands/next.md +251 -0
- package/.claude/commands/progress.md +242 -0
- package/.claude/commands/start.md +199 -0
- package/.claude/commands/sync.md +307 -0
- package/.claude/commands/update-status.md +428 -0
- package/.claude/docs/Mixin/344/275/277/347/224/250/346/214/207/345/215/227.md +299 -0
- package/.claude/docs/README.md +167 -0
- package/.claude/docs//345/211/215/347/253/257/345/274/200/345/217/221/346/214/207/345/215/227.md +599 -0
- package/.claude/docs//345/220/216/347/253/257/345/274/200/345/217/221/346/214/207/345/215/227.md +726 -0
- package/.claude/docs//345/267/245/344/275/234/346/265/201/345/274/200/345/217/221/346/214/207/345/215/227.md +714 -0
- package/.claude/docs//345/267/245/345/205/267/347/261/273/344/275/277/347/224/250/346/214/207/345/215/227.md +463 -0
- package/.claude/docs//346/225/260/346/215/256/345/272/223/350/256/276/350/256/241/350/247/204/350/214/203.md +390 -0
- package/.claude/docs//346/226/260/345/212/237/350/203/275/345/274/200/345/217/221/346/265/201/347/250/213/350/247/204/350/214/203.md +688 -0
- package/.claude/docs//346/226/260/351/241/271/347/233/256/345/274/200/345/217/221/346/265/201/347/250/213.md +365 -0
- package/.claude/docs//346/241/206/346/236/266/350/257/264/346/230/216.md +393 -0
- package/.claude/docs//350/267/257/347/224/261/351/205/215/347/275/256/346/214/207/345/215/227.md +246 -0
- package/.claude/framework-config.json +73 -0
- package/.claude/hooks/pre-tool-use.js +117 -0
- package/.claude/hooks/skill-forced-eval.js +167 -0
- package/.claude/hooks/stop.js +58 -0
- package/.claude/settings.json +41 -0
- package/.claude/skills/add-skill/SKILL.md +352 -0
- package/.claude/skills/api-development/SKILL.md +560 -0
- package/.claude/skills/architecture-design/SKILL.md +756 -0
- package/.claude/skills/backend-annotations/SKILL.md +674 -0
- package/.claude/skills/banana-image/CHANGELOG.md +37 -0
- package/.claude/skills/banana-image/README.md +146 -0
- package/.claude/skills/banana-image/SKILL.md +164 -0
- package/.claude/skills/banana-image/assets/logo.png +0 -0
- package/.claude/skills/banana-image/references/advanced-usage.md +189 -0
- package/.claude/skills/banana-image/scripts/apply_template.py +125 -0
- package/.claude/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/.claude/skills/banana-image/scripts/batch_prep.py +82 -0
- package/.claude/skills/banana-image/scripts/package-lock.json +1437 -0
- package/.claude/skills/banana-image/scripts/package.json +18 -0
- package/.claude/skills/banana-image/scripts/requirements.txt +10 -0
- package/.claude/skills/banana-image/templates/poster.json +22 -0
- package/.claude/skills/banana-image/templates/product.json +17 -0
- package/.claude/skills/banana-image/templates/social.json +22 -0
- package/.claude/skills/banana-image/templates/thumbnail.json +17 -0
- package/.claude/skills/brainstorm/SKILL.md +648 -0
- package/.claude/skills/bug-detective/SKILL.md +1206 -0
- package/.claude/skills/code-patterns/SKILL.md +590 -0
- package/.claude/skills/collaborating-with-codex/SKILL.md +174 -0
- package/.claude/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/.claude/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/.claude/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/.claude/skills/crud-development/SKILL.md +649 -0
- package/.claude/skills/data-permission/SKILL.md +599 -0
- package/.claude/skills/database-ops/SKILL.md +407 -0
- package/.claude/skills/error-handler/SKILL.md +371 -0
- package/.claude/skills/file-oss-management/SKILL.md +863 -0
- package/.claude/skills/git-workflow/SKILL.md +375 -0
- package/.claude/skills/json-serialization/SKILL.md +357 -0
- package/.claude/skills/leniu-api-development/SKILL.md +803 -0
- package/.claude/skills/leniu-architecture-design/SKILL.md +598 -0
- package/.claude/skills/leniu-backend-annotations/SKILL.md +664 -0
- package/.claude/skills/leniu-code-patterns/SKILL.md +365 -0
- package/.claude/skills/leniu-crud-development/SKILL.md +1110 -0
- package/.claude/skills/leniu-data-permission/SKILL.md +256 -0
- package/.claude/skills/leniu-database-ops/SKILL.md +426 -0
- package/.claude/skills/leniu-error-handler/SKILL.md +462 -0
- package/.claude/skills/leniu-java-amount-handling/SKILL.md +461 -0
- package/.claude/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.claude/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/.claude/skills/leniu-java-entity/SKILL.md +751 -0
- package/.claude/skills/leniu-java-export/SKILL.md +560 -0
- package/.claude/skills/leniu-java-logging/SKILL.md +832 -0
- package/.claude/skills/leniu-java-mq/SKILL.md +338 -0
- package/.claude/skills/leniu-java-mybatis/SKILL.md +640 -0
- package/.claude/skills/leniu-java-report-query-param/SKILL.md +291 -0
- package/.claude/skills/leniu-java-task/SKILL.md +367 -0
- package/.claude/skills/leniu-java-total-line/SKILL.md +195 -0
- package/.claude/skills/leniu-marketing-price-rule-customizer/SKILL.md +301 -0
- package/.claude/skills/leniu-marketing-recharge-rule-customizer/SKILL.md +285 -0
- package/.claude/skills/leniu-mealtime/SKILL.md +215 -0
- package/.claude/skills/leniu-redis-cache/SKILL.md +316 -0
- package/.claude/skills/leniu-security-guard/SKILL.md +520 -0
- package/.claude/skills/leniu-utils-toolkit/SKILL.md +380 -0
- package/.claude/skills/openspec-apply-change/SKILL.md +156 -0
- package/.claude/skills/openspec-archive-change/SKILL.md +114 -0
- package/.claude/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.claude/skills/openspec-continue-change/SKILL.md +118 -0
- package/.claude/skills/openspec-explore/SKILL.md +290 -0
- package/.claude/skills/openspec-ff-change/SKILL.md +101 -0
- package/.claude/skills/openspec-new-change/SKILL.md +74 -0
- package/.claude/skills/openspec-onboard/SKILL.md +529 -0
- package/.claude/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.claude/skills/openspec-verify-change/SKILL.md +168 -0
- package/.claude/skills/performance-doctor/SKILL.md +627 -0
- package/.claude/skills/project-navigator/SKILL.md +305 -0
- package/.claude/skills/redis-cache/SKILL.md +839 -0
- package/.claude/skills/scheduled-jobs/SKILL.md +633 -0
- package/.claude/skills/security-guard/SKILL.md +748 -0
- package/.claude/skills/sms-mail/SKILL.md +766 -0
- package/.claude/skills/social-login/SKILL.md +668 -0
- package/.claude/skills/store-pc/SKILL.md +366 -0
- package/.claude/skills/task-tracker/SKILL.md +307 -0
- package/.claude/skills/tech-decision/SKILL.md +393 -0
- package/.claude/skills/tenant-management/SKILL.md +603 -0
- package/.claude/skills/test-development/SKILL.md +755 -0
- package/.claude/skills/ui-pc/SKILL.md +438 -0
- package/.claude/skills/utils-toolkit/SKILL.md +615 -0
- package/.claude/skills/websocket-sse/SKILL.md +716 -0
- package/.claude/skills/workflow-engine/SKILL.md +676 -0
- package/.claude/templates//345/276/205/345/212/236/346/270/205/345/215/225/346/250/241/346/235/277.md +56 -0
- package/.claude/templates//351/234/200/346/261/202/346/226/207/346/241/243/346/250/241/346/235/277.md +85 -0
- package/.claude/templates//351/241/271/347/233/256/347/212/266/346/200/201/346/250/241/346/235/277.md +43 -0
- package/.codex/skills/add-skill/SKILL.md +352 -0
- package/.codex/skills/add-todo/SKILL.md +269 -0
- package/.codex/skills/api-development/SKILL.md +693 -0
- package/.codex/skills/architecture-design/SKILL.md +628 -0
- package/.codex/skills/backend-annotations/SKILL.md +664 -0
- package/.codex/skills/banana-image/CHANGELOG.md +37 -0
- package/.codex/skills/banana-image/README.md +146 -0
- package/.codex/skills/banana-image/SKILL.md +164 -0
- package/.codex/skills/banana-image/assets/logo.png +0 -0
- package/.codex/skills/banana-image/references/advanced-usage.md +189 -0
- package/.codex/skills/banana-image/scripts/apply_template.py +125 -0
- package/.codex/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/.codex/skills/banana-image/scripts/batch_prep.py +82 -0
- package/.codex/skills/banana-image/scripts/package-lock.json +1437 -0
- package/.codex/skills/banana-image/scripts/package.json +18 -0
- package/.codex/skills/banana-image/scripts/requirements.txt +10 -0
- package/.codex/skills/banana-image/templates/poster.json +22 -0
- package/.codex/skills/banana-image/templates/product.json +17 -0
- package/.codex/skills/banana-image/templates/social.json +22 -0
- package/.codex/skills/banana-image/templates/thumbnail.json +17 -0
- package/.codex/skills/brainstorm/SKILL.md +648 -0
- package/.codex/skills/bug-detective/SKILL.md +1206 -0
- package/.codex/skills/check/SKILL.md +367 -0
- package/.codex/skills/code-patterns/SKILL.md +442 -0
- package/.codex/skills/collaborating-with-codex/SKILL.md +174 -0
- package/.codex/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/.codex/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/.codex/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/.codex/skills/crud/SKILL.md +265 -0
- package/.codex/skills/crud-development/SKILL.md +637 -0
- package/.codex/skills/data-permission/SKILL.md +591 -0
- package/.codex/skills/database-ops/SKILL.md +553 -0
- package/.codex/skills/dev/SKILL.md +187 -0
- package/.codex/skills/error-handler/SKILL.md +361 -0
- package/.codex/skills/file-oss-management/SKILL.md +863 -0
- package/.codex/skills/git-workflow/SKILL.md +375 -0
- package/.codex/skills/init-docs/SKILL.md +194 -0
- package/.codex/skills/json-serialization/SKILL.md +357 -0
- package/.codex/skills/leniu-api-development/SKILL.md +803 -0
- package/.codex/skills/leniu-architecture-design/SKILL.md +594 -0
- package/.codex/skills/leniu-backend-annotations/SKILL.md +662 -0
- package/.codex/skills/leniu-code-patterns/SKILL.md +365 -0
- package/.codex/skills/leniu-crud-development/SKILL.md +1110 -0
- package/.codex/skills/leniu-data-permission/SKILL.md +256 -0
- package/.codex/skills/leniu-database-ops/SKILL.md +426 -0
- package/.codex/skills/leniu-error-handler/SKILL.md +462 -0
- package/.codex/skills/leniu-java-amount-handling/SKILL.md +461 -0
- package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.codex/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/.codex/skills/leniu-java-entity/SKILL.md +751 -0
- package/.codex/skills/leniu-java-export/SKILL.md +560 -0
- package/.codex/skills/leniu-java-logging/SKILL.md +832 -0
- package/.codex/skills/leniu-java-mq/SKILL.md +338 -0
- package/.codex/skills/leniu-java-mybatis/SKILL.md +640 -0
- package/.codex/skills/leniu-java-report-query-param/SKILL.md +291 -0
- package/.codex/skills/leniu-java-task/SKILL.md +367 -0
- package/.codex/skills/leniu-java-total-line/SKILL.md +195 -0
- package/.codex/skills/leniu-marketing-price-rule-customizer/SKILL.md +301 -0
- package/.codex/skills/leniu-marketing-recharge-rule-customizer/SKILL.md +285 -0
- package/.codex/skills/leniu-mealtime/SKILL.md +215 -0
- package/.codex/skills/leniu-redis-cache/SKILL.md +316 -0
- package/.codex/skills/leniu-security-guard/SKILL.md +520 -0
- package/.codex/skills/leniu-utils-toolkit/SKILL.md +378 -0
- package/.codex/skills/next/SKILL.md +137 -0
- package/.codex/skills/openspec-apply-change/SKILL.md +156 -0
- package/.codex/skills/openspec-archive-change/SKILL.md +114 -0
- package/.codex/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.codex/skills/openspec-continue-change/SKILL.md +118 -0
- package/.codex/skills/openspec-explore/SKILL.md +290 -0
- package/.codex/skills/openspec-ff-change/SKILL.md +101 -0
- package/.codex/skills/openspec-new-change/SKILL.md +74 -0
- package/.codex/skills/openspec-onboard/SKILL.md +529 -0
- package/.codex/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.codex/skills/openspec-verify-change/SKILL.md +168 -0
- package/.codex/skills/performance-doctor/SKILL.md +627 -0
- package/.codex/skills/progress/SKILL.md +193 -0
- package/.codex/skills/project-navigator/SKILL.md +286 -0
- package/.codex/skills/redis-cache/SKILL.md +829 -0
- package/.codex/skills/scheduled-jobs/SKILL.md +633 -0
- package/.codex/skills/security-guard/SKILL.md +739 -0
- package/.codex/skills/sms-mail/SKILL.md +766 -0
- package/.codex/skills/social-login/SKILL.md +668 -0
- package/.codex/skills/start/SKILL.md +154 -0
- package/.codex/skills/store-pc/SKILL.md +491 -0
- package/.codex/skills/sync/SKILL.md +149 -0
- package/.codex/skills/task-tracker/SKILL.md +307 -0
- package/.codex/skills/tech-decision/SKILL.md +393 -0
- package/.codex/skills/tenant-management/SKILL.md +603 -0
- package/.codex/skills/test-development/SKILL.md +755 -0
- package/.codex/skills/ui-pc/SKILL.md +475 -0
- package/.codex/skills/update-status/SKILL.md +159 -0
- package/.codex/skills/utils-toolkit/SKILL.md +593 -0
- package/.codex/skills/websocket-sse/SKILL.md +716 -0
- package/.codex/skills/workflow-engine/SKILL.md +676 -0
- package/.cursor/agents/code-reviewer.md +139 -0
- package/.cursor/agents/project-manager.md +159 -0
- package/.cursor/commands/opsx-apply.md +152 -0
- package/.cursor/commands/opsx-archive.md +157 -0
- package/.cursor/commands/opsx-bulk-archive.md +242 -0
- package/.cursor/commands/opsx-continue.md +114 -0
- package/.cursor/commands/opsx-explore.md +174 -0
- package/.cursor/commands/opsx-ff.md +94 -0
- package/.cursor/commands/opsx-new.md +69 -0
- package/.cursor/commands/opsx-onboard.md +525 -0
- package/.cursor/commands/opsx-sync.md +134 -0
- package/.cursor/commands/opsx-verify.md +164 -0
- package/.cursor/mcp.json +22 -0
- package/.cursor/skills/add-skill/SKILL.md +352 -0
- package/.cursor/skills/api-development/SKILL.md +560 -0
- package/.cursor/skills/architecture-design/SKILL.md +756 -0
- package/.cursor/skills/backend-annotations/SKILL.md +674 -0
- package/.cursor/skills/banana-image/CHANGELOG.md +37 -0
- package/.cursor/skills/banana-image/README.md +146 -0
- package/.cursor/skills/banana-image/SKILL.md +164 -0
- package/.cursor/skills/banana-image/assets/logo.png +0 -0
- package/.cursor/skills/banana-image/references/advanced-usage.md +189 -0
- package/.cursor/skills/banana-image/scripts/apply_template.py +125 -0
- package/.cursor/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/.cursor/skills/banana-image/scripts/batch_prep.py +82 -0
- package/.cursor/skills/banana-image/scripts/package-lock.json +1437 -0
- package/.cursor/skills/banana-image/scripts/package.json +18 -0
- package/.cursor/skills/banana-image/scripts/requirements.txt +10 -0
- package/.cursor/skills/banana-image/templates/poster.json +22 -0
- package/.cursor/skills/banana-image/templates/product.json +17 -0
- package/.cursor/skills/banana-image/templates/social.json +22 -0
- package/.cursor/skills/banana-image/templates/thumbnail.json +17 -0
- package/.cursor/skills/brainstorm/SKILL.md +648 -0
- package/.cursor/skills/bug-detective/SKILL.md +1206 -0
- package/.cursor/skills/code-patterns/SKILL.md +590 -0
- package/.cursor/skills/collaborating-with-codex/SKILL.md +174 -0
- package/.cursor/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/.cursor/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/.cursor/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/.cursor/skills/crud-development/SKILL.md +649 -0
- package/.cursor/skills/data-permission/SKILL.md +599 -0
- package/.cursor/skills/database-ops/SKILL.md +407 -0
- package/.cursor/skills/error-handler/SKILL.md +371 -0
- package/.cursor/skills/file-oss-management/SKILL.md +863 -0
- package/.cursor/skills/git-workflow/SKILL.md +375 -0
- package/.cursor/skills/json-serialization/SKILL.md +357 -0
- package/.cursor/skills/leniu-api-development/SKILL.md +803 -0
- package/.cursor/skills/leniu-architecture-design/SKILL.md +598 -0
- package/.cursor/skills/leniu-backend-annotations/SKILL.md +664 -0
- package/.cursor/skills/leniu-code-patterns/SKILL.md +365 -0
- package/.cursor/skills/leniu-crud-development/SKILL.md +1110 -0
- package/.cursor/skills/leniu-data-permission/SKILL.md +256 -0
- package/.cursor/skills/leniu-database-ops/SKILL.md +426 -0
- package/.cursor/skills/leniu-error-handler/SKILL.md +462 -0
- package/.cursor/skills/leniu-java-amount-handling/SKILL.md +461 -0
- package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.cursor/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/.cursor/skills/leniu-java-entity/SKILL.md +751 -0
- package/.cursor/skills/leniu-java-export/SKILL.md +560 -0
- package/.cursor/skills/leniu-java-logging/SKILL.md +832 -0
- package/.cursor/skills/leniu-java-mq/SKILL.md +338 -0
- package/.cursor/skills/leniu-java-mybatis/SKILL.md +640 -0
- package/.cursor/skills/leniu-java-report-query-param/SKILL.md +291 -0
- package/.cursor/skills/leniu-java-task/SKILL.md +367 -0
- package/.cursor/skills/leniu-java-total-line/SKILL.md +195 -0
- package/.cursor/skills/leniu-marketing-price-rule-customizer/SKILL.md +301 -0
- package/.cursor/skills/leniu-marketing-recharge-rule-customizer/SKILL.md +285 -0
- package/.cursor/skills/leniu-mealtime/SKILL.md +215 -0
- package/.cursor/skills/leniu-redis-cache/SKILL.md +316 -0
- package/.cursor/skills/leniu-security-guard/SKILL.md +520 -0
- package/.cursor/skills/leniu-utils-toolkit/SKILL.md +380 -0
- package/.cursor/skills/openspec-apply-change/SKILL.md +156 -0
- package/.cursor/skills/openspec-archive-change/SKILL.md +114 -0
- package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.cursor/skills/openspec-continue-change/SKILL.md +118 -0
- package/.cursor/skills/openspec-explore/SKILL.md +290 -0
- package/.cursor/skills/openspec-ff-change/SKILL.md +101 -0
- package/.cursor/skills/openspec-new-change/SKILL.md +74 -0
- package/.cursor/skills/openspec-onboard/SKILL.md +529 -0
- package/.cursor/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.cursor/skills/openspec-verify-change/SKILL.md +168 -0
- package/.cursor/skills/performance-doctor/SKILL.md +627 -0
- package/.cursor/skills/project-navigator/SKILL.md +305 -0
- package/.cursor/skills/redis-cache/SKILL.md +839 -0
- package/.cursor/skills/scheduled-jobs/SKILL.md +633 -0
- package/.cursor/skills/security-guard/SKILL.md +748 -0
- package/.cursor/skills/sms-mail/SKILL.md +766 -0
- package/.cursor/skills/social-login/SKILL.md +668 -0
- package/.cursor/skills/store-pc/SKILL.md +366 -0
- package/.cursor/skills/task-tracker/SKILL.md +307 -0
- package/.cursor/skills/tech-decision/SKILL.md +393 -0
- package/.cursor/skills/tenant-management/SKILL.md +603 -0
- package/.cursor/skills/test-development/SKILL.md +755 -0
- package/.cursor/skills/ui-pc/SKILL.md +438 -0
- package/.cursor/skills/utils-toolkit/SKILL.md +615 -0
- package/.cursor/skills/websocket-sse/SKILL.md +716 -0
- package/.cursor/skills/workflow-engine/SKILL.md +676 -0
- package/AGENTS.md +669 -0
- package/CLAUDE.md +205 -0
- package/README.md +205 -0
- package/bin/index.js +179 -0
- package/init.sh +178 -0
- package/package.json +27 -0
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: social-login
|
|
3
|
+
description: |
|
|
4
|
+
当需要实现第三方登录、OAuth2 认证、社交账号绑定时自动使用此 Skill。
|
|
5
|
+
|
|
6
|
+
触发场景:
|
|
7
|
+
- 需要接入微信/QQ/支付宝等第三方登录
|
|
8
|
+
- 需要实现 OAuth2 授权流程
|
|
9
|
+
- 需要配置 JustAuth 第三方登录
|
|
10
|
+
- 需要实现社交账号与系统账号绑定
|
|
11
|
+
- 需要获取第三方用户信息
|
|
12
|
+
|
|
13
|
+
触发词:第三方登录、微信登录、QQ登录、OAuth、OAuth2、JustAuth、社交登录、扫码登录、AuthRequest、SocialUtils、授权登录、GitHub登录、钉钉登录
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# 第三方登录开发指南(JustAuth)
|
|
17
|
+
|
|
18
|
+
> **适用模块**:`ruoyi-common-social`(基于 JustAuth)
|
|
19
|
+
|
|
20
|
+
## 概述
|
|
21
|
+
|
|
22
|
+
本框架基于 **JustAuth** 实现第三方登录,支持 20+ 种社交平台的 OAuth2 授权登录。
|
|
23
|
+
|
|
24
|
+
**核心特性**:
|
|
25
|
+
- ✅ 开箱即用,配置即生效
|
|
26
|
+
- ✅ 支持 20+ 社交平台
|
|
27
|
+
- ✅ Redis 状态缓存(防 CSRF)
|
|
28
|
+
- ✅ 多租户支持
|
|
29
|
+
- ✅ 账号绑定机制
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 一、支持的第三方平台
|
|
34
|
+
|
|
35
|
+
### 1.1 已集成平台列表
|
|
36
|
+
|
|
37
|
+
| 平台 | source 标识 | 说明 |
|
|
38
|
+
|------|------------|------|
|
|
39
|
+
| 钉钉 | `dingtalk` | 钉钉扫码登录(V2) |
|
|
40
|
+
| 百度 | `baidu` | 百度账号登录 |
|
|
41
|
+
| GitHub | `github` | GitHub OAuth |
|
|
42
|
+
| Gitee | `gitee` | 码云账号登录 |
|
|
43
|
+
| 微博 | `weibo` | 新浪微博登录 |
|
|
44
|
+
| Coding | `coding` | Coding 账号登录 |
|
|
45
|
+
| 开源中国 | `oschina` | OSChina 账号登录 |
|
|
46
|
+
| 支付宝 | `alipay_wallet` | 支付宝钱包登录 |
|
|
47
|
+
| QQ | `qq` | QQ 互联登录 |
|
|
48
|
+
| 微信开放平台 | `wechat_open` | 微信扫码登录 |
|
|
49
|
+
| 微信公众号 | `wechat_mp` | 微信公众号授权 |
|
|
50
|
+
| 企业微信 | `wechat_enterprise` | 企业微信扫码登录 |
|
|
51
|
+
| 淘宝 | `taobao` | 淘宝账号登录 |
|
|
52
|
+
| 抖音 | `douyin` | 抖音账号登录 |
|
|
53
|
+
| LinkedIn | `linkedin` | 领英账号登录 |
|
|
54
|
+
| Microsoft | `microsoft` | 微软账号登录 |
|
|
55
|
+
| 人人网 | `renren` | 人人网账号登录 |
|
|
56
|
+
| StackOverflow | `stack_overflow` | StackOverflow 登录 |
|
|
57
|
+
| 华为 | `huawei` | 华为账号登录(V3) |
|
|
58
|
+
| GitLab | `gitlab` | GitLab 账号登录 |
|
|
59
|
+
| 阿里云 | `aliyun` | 阿里云账号登录 |
|
|
60
|
+
| MaxKey | `maxkey` | MaxKey 单点登录 |
|
|
61
|
+
| TopIAM | `topiam` | TopIAM 单点登录 |
|
|
62
|
+
| Gitea | `gitea` | Gitea 账号登录 |
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 二、配置第三方登录
|
|
67
|
+
|
|
68
|
+
### 2.1 基础配置
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
# application.yml
|
|
72
|
+
justauth:
|
|
73
|
+
type:
|
|
74
|
+
# GitHub 登录配置
|
|
75
|
+
github:
|
|
76
|
+
client-id: ${GITHUB_CLIENT_ID}
|
|
77
|
+
client-secret: ${GITHUB_CLIENT_SECRET}
|
|
78
|
+
redirect-uri: ${server.url}/social-callback?source=github
|
|
79
|
+
|
|
80
|
+
# Gitee 登录配置
|
|
81
|
+
gitee:
|
|
82
|
+
client-id: ${GITEE_CLIENT_ID}
|
|
83
|
+
client-secret: ${GITEE_CLIENT_SECRET}
|
|
84
|
+
redirect-uri: ${server.url}/social-callback?source=gitee
|
|
85
|
+
|
|
86
|
+
# 钉钉登录配置
|
|
87
|
+
dingtalk:
|
|
88
|
+
client-id: ${DINGTALK_APP_KEY}
|
|
89
|
+
client-secret: ${DINGTALK_APP_SECRET}
|
|
90
|
+
redirect-uri: ${server.url}/social-callback?source=dingtalk
|
|
91
|
+
|
|
92
|
+
# 微信开放平台配置
|
|
93
|
+
wechat_open:
|
|
94
|
+
client-id: ${WECHAT_APP_ID}
|
|
95
|
+
client-secret: ${WECHAT_APP_SECRET}
|
|
96
|
+
redirect-uri: ${server.url}/social-callback?source=wechat_open
|
|
97
|
+
|
|
98
|
+
# QQ 登录配置
|
|
99
|
+
qq:
|
|
100
|
+
client-id: ${QQ_APP_ID}
|
|
101
|
+
client-secret: ${QQ_APP_KEY}
|
|
102
|
+
redirect-uri: ${server.url}/social-callback?source=qq
|
|
103
|
+
union-id: true # 是否获取 unionId
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 2.2 特殊平台配置
|
|
107
|
+
|
|
108
|
+
#### 微软登录(需要 tenantId)
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
justauth:
|
|
112
|
+
type:
|
|
113
|
+
microsoft:
|
|
114
|
+
client-id: ${MICROSOFT_CLIENT_ID}
|
|
115
|
+
client-secret: ${MICROSOFT_CLIENT_SECRET}
|
|
116
|
+
redirect-uri: ${server.url}/social-callback?source=microsoft
|
|
117
|
+
tenant-id: common # common、organizations、consumers 或具体租户ID
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### 企业微信(需要 agentId)
|
|
121
|
+
|
|
122
|
+
```yaml
|
|
123
|
+
justauth:
|
|
124
|
+
type:
|
|
125
|
+
wechat_enterprise:
|
|
126
|
+
client-id: ${WECHAT_CORP_ID}
|
|
127
|
+
client-secret: ${WECHAT_CORP_SECRET}
|
|
128
|
+
redirect-uri: ${server.url}/social-callback?source=wechat_enterprise
|
|
129
|
+
agent-id: ${WECHAT_AGENT_ID}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### 支付宝(需要公钥)
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
justauth:
|
|
136
|
+
type:
|
|
137
|
+
alipay_wallet:
|
|
138
|
+
client-id: ${ALIPAY_APP_ID}
|
|
139
|
+
client-secret: ${ALIPAY_PRIVATE_KEY}
|
|
140
|
+
redirect-uri: ${server.url}/social-callback?source=alipay_wallet
|
|
141
|
+
alipay-public-key: ${ALIPAY_PUBLIC_KEY}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 三、核心 API
|
|
147
|
+
|
|
148
|
+
### 3.1 SocialUtils 工具类
|
|
149
|
+
|
|
150
|
+
**位置**:`org.dromara.common.social.utils.SocialUtils`
|
|
151
|
+
|
|
152
|
+
```java
|
|
153
|
+
import org.dromara.common.social.utils.SocialUtils;
|
|
154
|
+
import org.dromara.common.social.config.properties.SocialProperties;
|
|
155
|
+
import me.zhyd.oauth.model.AuthResponse;
|
|
156
|
+
import me.zhyd.oauth.model.AuthUser;
|
|
157
|
+
import me.zhyd.oauth.request.AuthRequest;
|
|
158
|
+
|
|
159
|
+
// ========== 获取授权请求 ==========
|
|
160
|
+
|
|
161
|
+
// 1. 获取指定平台的授权请求对象
|
|
162
|
+
AuthRequest authRequest = SocialUtils.getAuthRequest("github", socialProperties);
|
|
163
|
+
|
|
164
|
+
// 2. 生成授权 URL(跳转到第三方登录页)
|
|
165
|
+
String authorizeUrl = authRequest.authorize("随机state");
|
|
166
|
+
|
|
167
|
+
// ========== 处理回调登录 ==========
|
|
168
|
+
|
|
169
|
+
// 3. 处理第三方回调,获取用户信息
|
|
170
|
+
AuthResponse<AuthUser> response = SocialUtils.loginAuth(
|
|
171
|
+
"github", // 平台标识
|
|
172
|
+
code, // 授权码
|
|
173
|
+
state, // 状态码(防 CSRF)
|
|
174
|
+
socialProperties // 配置属性
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
// 4. 检查登录结果
|
|
178
|
+
if (response.ok()) {
|
|
179
|
+
AuthUser authUser = response.getData();
|
|
180
|
+
String openId = authUser.getUuid(); // 用户唯一标识
|
|
181
|
+
String nickname = authUser.getNickname(); // 昵称
|
|
182
|
+
String avatar = authUser.getAvatar(); // 头像
|
|
183
|
+
String source = authUser.getSource(); // 来源平台
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 3.2 AuthUser 用户信息
|
|
188
|
+
|
|
189
|
+
```java
|
|
190
|
+
// JustAuth 返回的用户信息
|
|
191
|
+
public class AuthUser {
|
|
192
|
+
private String uuid; // 第三方平台用户唯一ID
|
|
193
|
+
private String username; // 用户名
|
|
194
|
+
private String nickname; // 昵称
|
|
195
|
+
private String avatar; // 头像
|
|
196
|
+
private String blog; // 博客地址
|
|
197
|
+
private String company; // 公司
|
|
198
|
+
private String location; // 位置
|
|
199
|
+
private String email; // 邮箱
|
|
200
|
+
private String remark; // 备注
|
|
201
|
+
private AuthUserGender gender; // 性别
|
|
202
|
+
private String source; // 来源平台(github、gitee 等)
|
|
203
|
+
private AuthToken token; // Token 信息
|
|
204
|
+
private Map<String, Object> rawUserInfo; // 原始用户信息
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### 3.3 状态缓存(AuthRedisStateCache)
|
|
209
|
+
|
|
210
|
+
**位置**:`org.dromara.common.social.utils.AuthRedisStateCache`
|
|
211
|
+
|
|
212
|
+
框架使用 Redis 缓存 OAuth2 state 参数,防止 CSRF 攻击:
|
|
213
|
+
|
|
214
|
+
```java
|
|
215
|
+
// 自动注入,无需手动操作
|
|
216
|
+
// 授权 URL 生成时自动存入 state
|
|
217
|
+
// 回调验证时自动校验 state
|
|
218
|
+
// 默认过期时间:3 分钟
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 四、完整登录流程
|
|
224
|
+
|
|
225
|
+
### 4.1 流程图
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
┌─────────────┐ 1. 点击第三方登录 ┌─────────────┐
|
|
229
|
+
│ 前端页面 │ ────────────────────────→ │ 后端服务 │
|
|
230
|
+
└─────────────┘ └─────────────┘
|
|
231
|
+
│
|
|
232
|
+
2. 生成授权 URL(含 state)
|
|
233
|
+
│
|
|
234
|
+
▼
|
|
235
|
+
┌─────────────┐ 3. 跳转授权页面 ┌─────────────┐
|
|
236
|
+
│ 前端页面 │ ←─────────────────────── │ 后端服务 │
|
|
237
|
+
└─────────────┘ └─────────────┘
|
|
238
|
+
│
|
|
239
|
+
│ 4. 用户在第三方平台授权
|
|
240
|
+
▼
|
|
241
|
+
┌─────────────┐ 5. 回调(code+state) ┌─────────────┐
|
|
242
|
+
│ 第三方平台 │ ────────────────────────→ │ 后端服务 │
|
|
243
|
+
└─────────────┘ └─────────────┘
|
|
244
|
+
│
|
|
245
|
+
6. 用 code 换取用户信息
|
|
246
|
+
│
|
|
247
|
+
7. 查找绑定关系 / 创建用户
|
|
248
|
+
│
|
|
249
|
+
8. 生成系统 Token
|
|
250
|
+
▼
|
|
251
|
+
┌─────────────┐ 9. 返回登录结果 ┌─────────────┐
|
|
252
|
+
│ 前端页面 │ ←─────────────────────── │ 后端服务 │
|
|
253
|
+
└─────────────┘ └─────────────┘
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 4.2 后端实现示例
|
|
257
|
+
|
|
258
|
+
#### 步骤1:生成授权 URL
|
|
259
|
+
|
|
260
|
+
```java
|
|
261
|
+
@RestController
|
|
262
|
+
@RequestMapping("/auth")
|
|
263
|
+
@RequiredArgsConstructor
|
|
264
|
+
public class AuthController {
|
|
265
|
+
|
|
266
|
+
private final SocialProperties socialProperties;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 获取第三方登录授权 URL
|
|
270
|
+
*
|
|
271
|
+
* @param source 平台标识(github、gitee、dingtalk 等)
|
|
272
|
+
*/
|
|
273
|
+
@GetMapping("/binding/{source}")
|
|
274
|
+
public R<String> authBinding(@PathVariable String source) {
|
|
275
|
+
// 获取授权请求对象
|
|
276
|
+
AuthRequest authRequest = SocialUtils.getAuthRequest(source, socialProperties);
|
|
277
|
+
|
|
278
|
+
// 生成随机 state(自动存入 Redis)
|
|
279
|
+
String state = AuthStateUtils.createState();
|
|
280
|
+
|
|
281
|
+
// 生成授权 URL
|
|
282
|
+
String authorizeUrl = authRequest.authorize(state);
|
|
283
|
+
|
|
284
|
+
return R.ok("操作成功", authorizeUrl);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### 步骤2:处理回调登录
|
|
290
|
+
|
|
291
|
+
```java
|
|
292
|
+
@Slf4j
|
|
293
|
+
@Service("social" + IAuthStrategy.BASE_NAME)
|
|
294
|
+
@RequiredArgsConstructor
|
|
295
|
+
public class SocialAuthStrategy implements IAuthStrategy {
|
|
296
|
+
|
|
297
|
+
private final SocialProperties socialProperties;
|
|
298
|
+
private final ISysSocialService sysSocialService;
|
|
299
|
+
private final SysUserMapper userMapper;
|
|
300
|
+
private final SysLoginService loginService;
|
|
301
|
+
|
|
302
|
+
@Override
|
|
303
|
+
public LoginVo login(String body, SysClientVo client) {
|
|
304
|
+
SocialLoginBody loginBody = JsonUtils.parseObject(body, SocialLoginBody.class);
|
|
305
|
+
ValidatorUtils.validate(loginBody);
|
|
306
|
+
|
|
307
|
+
// 1. 调用第三方登录,获取用户信息
|
|
308
|
+
AuthResponse<AuthUser> response = SocialUtils.loginAuth(
|
|
309
|
+
loginBody.getSource(),
|
|
310
|
+
loginBody.getSocialCode(),
|
|
311
|
+
loginBody.getSocialState(),
|
|
312
|
+
socialProperties
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
if (!response.ok()) {
|
|
316
|
+
throw new ServiceException(response.getMsg());
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
AuthUser authUserData = response.getData();
|
|
320
|
+
|
|
321
|
+
// 2. 根据 authId 查找绑定关系
|
|
322
|
+
String authId = authUserData.getSource() + authUserData.getUuid();
|
|
323
|
+
List<SysSocialVo> list = sysSocialService.selectByAuthId(authId);
|
|
324
|
+
|
|
325
|
+
if (CollUtil.isEmpty(list)) {
|
|
326
|
+
throw new ServiceException("你还没有绑定第三方账号,绑定后才可以登录!");
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// 3. 加载系统用户并生成 Token
|
|
330
|
+
SysSocialVo social = list.get(0);
|
|
331
|
+
LoginUser loginUser = loginService.buildLoginUser(loadUser(social.getUserId()));
|
|
332
|
+
|
|
333
|
+
// 4. 登录并返回 Token
|
|
334
|
+
LoginHelper.login(loginUser, new SaLoginParameter()
|
|
335
|
+
.setDeviceType(client.getDeviceType())
|
|
336
|
+
.setTimeout(client.getTimeout())
|
|
337
|
+
.setActiveTimeout(client.getActiveTimeout()));
|
|
338
|
+
|
|
339
|
+
LoginVo loginVo = new LoginVo();
|
|
340
|
+
loginVo.setAccessToken(StpUtil.getTokenValue());
|
|
341
|
+
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
|
342
|
+
return loginVo;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### 4.3 账号绑定实现
|
|
348
|
+
|
|
349
|
+
绑定入口:`AuthController.socialCallback()` → `SysLoginService.socialRegister()`
|
|
350
|
+
|
|
351
|
+
```java
|
|
352
|
+
// 位置:ruoyi-admin/.../web/controller/AuthController.java
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* 前端回调绑定授权(需要token)
|
|
356
|
+
*/
|
|
357
|
+
@PostMapping("/social/callback")
|
|
358
|
+
public R<Void> socialCallback(@RequestBody SocialLoginBody loginBody) {
|
|
359
|
+
StpUtil.checkLogin();
|
|
360
|
+
AuthResponse<AuthUser> response = SocialUtils.loginAuth(
|
|
361
|
+
loginBody.getSource(), loginBody.getSocialCode(),
|
|
362
|
+
loginBody.getSocialState(), socialProperties);
|
|
363
|
+
if (!response.ok()) {
|
|
364
|
+
return R.fail(response.getMsg());
|
|
365
|
+
}
|
|
366
|
+
loginService.socialRegister(response.getData());
|
|
367
|
+
return R.ok();
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
```java
|
|
372
|
+
// 位置:ruoyi-admin/.../web/service/SysLoginService.java
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 绑定第三方用户
|
|
376
|
+
*/
|
|
377
|
+
@Lock4j
|
|
378
|
+
public void socialRegister(AuthUser authUserData) {
|
|
379
|
+
String authId = authUserData.getSource() + authUserData.getUuid();
|
|
380
|
+
// 第三方用户信息转 BO
|
|
381
|
+
SysSocialBo bo = BeanUtil.toBean(authUserData, SysSocialBo.class);
|
|
382
|
+
BeanUtil.copyProperties(authUserData.getToken(), bo);
|
|
383
|
+
Long userId = LoginHelper.getUserId();
|
|
384
|
+
bo.setUserId(userId);
|
|
385
|
+
bo.setAuthId(authId);
|
|
386
|
+
bo.setOpenId(authUserData.getUuid());
|
|
387
|
+
bo.setUserName(authUserData.getUsername());
|
|
388
|
+
bo.setNickName(authUserData.getNickname());
|
|
389
|
+
|
|
390
|
+
// 检查是否已被其他用户绑定
|
|
391
|
+
List<SysSocialVo> checkList = sysSocialService.selectByAuthId(authId);
|
|
392
|
+
if (CollUtil.isNotEmpty(checkList)) {
|
|
393
|
+
throw new ServiceException("此三方账号已经被绑定!");
|
|
394
|
+
}
|
|
395
|
+
// 查询当前用户是否已绑定该平台
|
|
396
|
+
SysSocialBo params = new SysSocialBo();
|
|
397
|
+
params.setUserId(userId);
|
|
398
|
+
params.setSource(bo.getSource());
|
|
399
|
+
List<SysSocialVo> list = sysSocialService.queryList(params);
|
|
400
|
+
if (CollUtil.isEmpty(list)) {
|
|
401
|
+
sysSocialService.insertByBo(bo); // 新增绑定
|
|
402
|
+
} else {
|
|
403
|
+
bo.setId(list.get(0).getId());
|
|
404
|
+
sysSocialService.updateByBo(bo); // 更新绑定
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
解绑入口:`AuthController.unlockSocial()`
|
|
410
|
+
|
|
411
|
+
```java
|
|
412
|
+
// 位置:ruoyi-admin/.../web/controller/AuthController.java
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* 取消授权(需要token)
|
|
416
|
+
*/
|
|
417
|
+
@DeleteMapping(value = "/unlock/{socialId}")
|
|
418
|
+
public R<Void> unlockSocial(@PathVariable Long socialId) {
|
|
419
|
+
StpUtil.checkLogin();
|
|
420
|
+
Boolean rows = socialUserService.deleteWithValidById(socialId);
|
|
421
|
+
return rows ? R.ok() : R.fail("取消授权失败");
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## 五、前端集成
|
|
428
|
+
|
|
429
|
+
### 5.1 跳转第三方授权
|
|
430
|
+
|
|
431
|
+
```javascript
|
|
432
|
+
// 获取授权 URL
|
|
433
|
+
async function getSocialLoginUrl(source) {
|
|
434
|
+
const { data } = await request.get(`/auth/binding/${source}`);
|
|
435
|
+
// 跳转到第三方授权页面
|
|
436
|
+
window.location.href = data;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// 点击登录按钮
|
|
440
|
+
function handleGitHubLogin() {
|
|
441
|
+
getSocialLoginUrl('github');
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function handleWeChatLogin() {
|
|
445
|
+
getSocialLoginUrl('wechat_open');
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### 5.2 处理回调
|
|
450
|
+
|
|
451
|
+
```javascript
|
|
452
|
+
// 回调页面 social-callback.vue
|
|
453
|
+
export default {
|
|
454
|
+
async mounted() {
|
|
455
|
+
const { source, code, state } = this.$route.query;
|
|
456
|
+
|
|
457
|
+
if (!code || !state) {
|
|
458
|
+
this.$message.error('授权失败');
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
try {
|
|
463
|
+
// 调用后端登录接口
|
|
464
|
+
const { data } = await request.post('/auth/login', {
|
|
465
|
+
grantType: 'social',
|
|
466
|
+
source: source,
|
|
467
|
+
socialCode: code,
|
|
468
|
+
socialState: state,
|
|
469
|
+
clientId: 'your-client-id'
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
// 保存 Token
|
|
473
|
+
setToken(data.accessToken);
|
|
474
|
+
|
|
475
|
+
// 跳转首页
|
|
476
|
+
this.$router.push('/');
|
|
477
|
+
} catch (error) {
|
|
478
|
+
this.$message.error(error.message || '登录失败');
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## 六、常见错误与最佳实践
|
|
487
|
+
|
|
488
|
+
### ❌ 错误1:回调地址配置错误
|
|
489
|
+
|
|
490
|
+
```yaml
|
|
491
|
+
# ❌ 错误:回调地址与第三方平台配置不一致
|
|
492
|
+
justauth:
|
|
493
|
+
type:
|
|
494
|
+
github:
|
|
495
|
+
redirect-uri: http://localhost:8080/callback # 本地地址
|
|
496
|
+
|
|
497
|
+
# ✅ 正确:使用与第三方平台一致的回调地址
|
|
498
|
+
justauth:
|
|
499
|
+
type:
|
|
500
|
+
github:
|
|
501
|
+
redirect-uri: https://your-domain.com/social-callback?source=github
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### ❌ 错误2:未处理 state 验证失败
|
|
505
|
+
|
|
506
|
+
```java
|
|
507
|
+
// ❌ 错误:不检查响应结果
|
|
508
|
+
AuthResponse<AuthUser> response = SocialUtils.loginAuth(...);
|
|
509
|
+
AuthUser user = response.getData(); // 可能为 null
|
|
510
|
+
|
|
511
|
+
// ✅ 正确:先检查响应状态
|
|
512
|
+
AuthResponse<AuthUser> response = SocialUtils.loginAuth(...);
|
|
513
|
+
if (!response.ok()) {
|
|
514
|
+
throw new ServiceException("授权失败:" + response.getMsg());
|
|
515
|
+
}
|
|
516
|
+
AuthUser user = response.getData();
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
### ❌ 错误3:未处理账号未绑定情况
|
|
520
|
+
|
|
521
|
+
```java
|
|
522
|
+
// ❌ 错误:直接使用绑定关系
|
|
523
|
+
List<SysSocialVo> list = sysSocialService.selectByAuthId(authId);
|
|
524
|
+
SysSocialVo social = list.get(0); // 可能 IndexOutOfBoundsException
|
|
525
|
+
|
|
526
|
+
// ✅ 正确:检查是否已绑定
|
|
527
|
+
List<SysSocialVo> list = sysSocialService.selectByAuthId(authId);
|
|
528
|
+
if (CollUtil.isEmpty(list)) {
|
|
529
|
+
throw new ServiceException("请先绑定第三方账号");
|
|
530
|
+
}
|
|
531
|
+
SysSocialVo social = list.get(0);
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### ❌ 错误4:source 标识拼写错误
|
|
535
|
+
|
|
536
|
+
```java
|
|
537
|
+
// ❌ 错误:使用错误的 source 标识
|
|
538
|
+
SocialUtils.getAuthRequest("wechat", socialProperties); // 不存在
|
|
539
|
+
|
|
540
|
+
// ✅ 正确:使用正确的 source 标识
|
|
541
|
+
SocialUtils.getAuthRequest("wechat_open", socialProperties); // 微信开放平台
|
|
542
|
+
SocialUtils.getAuthRequest("wechat_mp", socialProperties); // 微信公众号
|
|
543
|
+
SocialUtils.getAuthRequest("wechat_enterprise", socialProperties); // 企业微信
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
## 七、API 速查表
|
|
549
|
+
|
|
550
|
+
### SocialUtils 方法
|
|
551
|
+
|
|
552
|
+
| 方法 | 说明 |
|
|
553
|
+
|------|------|
|
|
554
|
+
| `getAuthRequest(source, properties)` | 获取指定平台的授权请求对象 |
|
|
555
|
+
| `loginAuth(source, code, state, properties)` | 处理回调登录,获取用户信息 |
|
|
556
|
+
|
|
557
|
+
### AuthRequest 方法
|
|
558
|
+
|
|
559
|
+
| 方法 | 说明 |
|
|
560
|
+
|------|------|
|
|
561
|
+
| `authorize(state)` | 生成授权 URL |
|
|
562
|
+
| `login(callback)` | 执行登录,获取用户信息 |
|
|
563
|
+
| `refresh(token)` | 刷新 Token |
|
|
564
|
+
| `revoke(token)` | 撤销授权 |
|
|
565
|
+
|
|
566
|
+
### AuthUser 属性
|
|
567
|
+
|
|
568
|
+
| 属性 | 说明 |
|
|
569
|
+
|------|------|
|
|
570
|
+
| `uuid` | 第三方平台用户唯一ID |
|
|
571
|
+
| `username` | 用户名 |
|
|
572
|
+
| `nickname` | 昵称 |
|
|
573
|
+
| `avatar` | 头像 URL |
|
|
574
|
+
| `email` | 邮箱 |
|
|
575
|
+
| `source` | 来源平台标识 |
|
|
576
|
+
| `token` | Token 信息(accessToken、refreshToken 等) |
|
|
577
|
+
| `rawUserInfo` | 原始用户信息(Map) |
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
581
|
+
## 八、配置参考
|
|
582
|
+
|
|
583
|
+
### 完整配置示例
|
|
584
|
+
|
|
585
|
+
```yaml
|
|
586
|
+
justauth:
|
|
587
|
+
type:
|
|
588
|
+
github:
|
|
589
|
+
client-id: ${GITHUB_CLIENT_ID:}
|
|
590
|
+
client-secret: ${GITHUB_CLIENT_SECRET:}
|
|
591
|
+
redirect-uri: ${justauth.address}/social-callback?source=github
|
|
592
|
+
|
|
593
|
+
gitee:
|
|
594
|
+
client-id: ${GITEE_CLIENT_ID:}
|
|
595
|
+
client-secret: ${GITEE_CLIENT_SECRET:}
|
|
596
|
+
redirect-uri: ${justauth.address}/social-callback?source=gitee
|
|
597
|
+
|
|
598
|
+
dingtalk:
|
|
599
|
+
client-id: ${DINGTALK_APP_KEY:}
|
|
600
|
+
client-secret: ${DINGTALK_APP_SECRET:}
|
|
601
|
+
redirect-uri: ${justauth.address}/social-callback?source=dingtalk
|
|
602
|
+
|
|
603
|
+
qq:
|
|
604
|
+
client-id: ${QQ_APP_ID:}
|
|
605
|
+
client-secret: ${QQ_APP_KEY:}
|
|
606
|
+
redirect-uri: ${justauth.address}/social-callback?source=qq
|
|
607
|
+
union-id: true
|
|
608
|
+
|
|
609
|
+
wechat_open:
|
|
610
|
+
client-id: ${WECHAT_OPEN_APP_ID:}
|
|
611
|
+
client-secret: ${WECHAT_OPEN_APP_SECRET:}
|
|
612
|
+
redirect-uri: ${justauth.address}/social-callback?source=wechat_open
|
|
613
|
+
|
|
614
|
+
wechat_mp:
|
|
615
|
+
client-id: ${WECHAT_MP_APP_ID:}
|
|
616
|
+
client-secret: ${WECHAT_MP_APP_SECRET:}
|
|
617
|
+
redirect-uri: ${justauth.address}/social-callback?source=wechat_mp
|
|
618
|
+
|
|
619
|
+
maxkey:
|
|
620
|
+
client-id: ${MAXKEY_CLIENT_ID:}
|
|
621
|
+
client-secret: ${MAXKEY_CLIENT_SECRET:}
|
|
622
|
+
redirect-uri: ${justauth.address}/social-callback?source=maxkey
|
|
623
|
+
server-url: ${MAXKEY_SERVER_URL:}
|
|
624
|
+
|
|
625
|
+
# 授权回调地址前缀
|
|
626
|
+
address: https://your-domain.com
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
---
|
|
630
|
+
|
|
631
|
+
## 九、参考代码位置
|
|
632
|
+
|
|
633
|
+
| 类型 | 位置 |
|
|
634
|
+
|------|------|
|
|
635
|
+
| 社交登录工具类 | `ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/SocialUtils.java` |
|
|
636
|
+
| 状态缓存 | `ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/utils/AuthRedisStateCache.java` |
|
|
637
|
+
| 配置属性 | `ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialProperties.java` |
|
|
638
|
+
| 登录配置属性 | `ruoyi-common/ruoyi-common-social/src/main/java/org/dromara/common/social/config/properties/SocialLoginConfigProperties.java` |
|
|
639
|
+
| 社交登录策略 | `ruoyi-admin/src/main/java/org/dromara/web/service/impl/SocialAuthStrategy.java` |
|
|
640
|
+
| 认证控制器 | `ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java` |
|
|
641
|
+
| 社交绑定服务 | `ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysSocialService.java` |
|
|
642
|
+
|
|
643
|
+
---
|
|
644
|
+
|
|
645
|
+
## 十、扩展:自定义第三方平台
|
|
646
|
+
|
|
647
|
+
如需接入框架未支持的第三方平台,可参考 `AuthGiteaRequest` 实现:
|
|
648
|
+
|
|
649
|
+
```java
|
|
650
|
+
public class AuthCustomRequest extends AuthDefaultRequest {
|
|
651
|
+
|
|
652
|
+
public AuthCustomRequest(AuthConfig config, AuthStateCache stateCache) {
|
|
653
|
+
super(config, AuthCustomSource.CUSTOM, stateCache);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
@Override
|
|
657
|
+
protected AuthToken getAccessToken(AuthCallback authCallback) {
|
|
658
|
+
// 实现获取 Token 的逻辑
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
@Override
|
|
662
|
+
protected AuthUser getUserInfo(AuthToken authToken) {
|
|
663
|
+
// 实现获取用户信息的逻辑
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
然后在 `SocialUtils.getAuthRequest()` 中添加对应的 case 分支。
|