Files
sso-portal/README.md
zhangheng 00d3de91f9 docs: document environment variables in README
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 19:46:45 +08:00

72 lines
2.0 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
```
## 环境变量
按环境拆分,已随仓库提交(参考 uirefbase 约定):`.env.development` / `.env.staging` / `.env.production`
本地私有覆盖请写入 `.env*.local`(已被 `.gitignore` 忽略,不入库)。
| 变量 | 说明 | 示例 |
|------|------|------|
| `NEXT_PUBLIC_BASE_PATH` | 部署子路径,无则留空 | `""` |
| `NEXT_PUBLIC_SHARED_API_PATH` | 后端 basis 服务地址(登录 / 验证码 / 租户列表都走这里) | dev: `http://172.16.115.31:6610/`<br>prod: `http://basis-app-svc:6610` |
> 无密钥可安全入库。Next.js 会按 `NODE_ENV` 自动加载对应文件(`next dev` → development`next build/start` → production
## 测试账号
| 账号 | 密码 | 姓名 |
|------|------|------|
| `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 | 测试用户列表 |