Files
sso-portal/README.md
zhangheng 37f10118d3 chore: initial commit of sso-mock SSO login service
Next.js + Mantine mock SSO service providing account/password, phone
verify-code, and Feishu QR login. Issues a one-time sso_code that the
external app exchanges for user info.

Includes:
- Feishu callback fix: guard against duplicate/concurrent /api/login
  submissions of the same single-use authorization code (feishuLogin
  once-guard + memoized onLoginSuccess to stop effect re-fire).
- ADAPTATION_GUIDE.md: how to switch from the in-memory code store to
  the real backend auth/index + inner_get_user_info endpoints.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 18:09:30 +08:00

59 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Mock SSO
基于 Next.js 16 + Mantine 8 的 Mock SSO 登录服务,登录页复用 uirefbase 的 UI 风格。
## 快速开始
```bash
pnpm install
pnpm dev # http://localhost:5501
```
## 测试账号
| 账号 | 密码 | 姓名 |
|------|------|------|
| `admin` | `123456` | 管理员 |
| `user01` | `123456` | 测试用户 |
| `zhangsan` | `123456` | 张三 |
手机号登录:任意 11 位手机号 + 任意 6 位验证码即可。
## SSO 登录流程
### 1. 外部应用发起 SSO 请求
```
http://localhost:5501/login?app_id=your_app_id&app_url=http%3A%2F%2Flocalhost%3A3000%2Fcallback
```
### 2. 用户在此页面登录
### 3. 登录成功后自动跳转
```
http://localhost:3000/callback?sso_code=xxxxx
```
### 4. 外部应用用 code 换取用户信息
```bash
curl -X POST http://localhost:5501/api/auth/verify \
-H "Content-Type: application/json" \
-d '{"code": "your_sso_code"}'
```
返回用户信息和 token。
## 直接访问
不带 `app_id` / `app_url` 参数访问 `/login`,登录成功后跳转到 `/dashboard` 管理后台。
## API
| 接口 | 方法 | 说明 |
|------|------|------|
| `/api/auth/login` | POST | 登录(返回 code 或 token |
| `/api/auth/verify` | POST | 验证 code 换取用户信息 |
| `/api/mock/users` | GET | 测试用户列表 |