背景: - 开发计划 A1 批次要求登录/刷新/登出、用户生命周期、路由与按钮权限、 权限三态用例;视觉已选定方案 B(主从分栏 + 分屏登录)。 改动: - packages/shared:新增 identity 契约(User/Me/Login/Refresh/Department/Role) 与 user:view 权限点;写接口 strict 校验。 - apps/api:新增 identity 模块与 Prisma expand 迁移(departments/users/roles/ user_roles/role_permissions/refresh_tokens);Argon2id、JWT access+refresh 旋转与 jti 吊销、登录失败锁定、首登强改、守卫链、/me、@Audit 上下文、幂等种子。 - apps/web:按方案 B 落地 /users、/users/new、/users/:id、分屏登录与 403; usePermission/<Can>、路由守卫、401 单飞刷新、停用会话兜底、Semi + token。 - e2e:新增 A1-QA-01 六类端到端用例(A1_E2E 门控)。 - openapi 与前端生成类型同步;.env.example 登记认证变量;实施报告入库。 影响面: - 新增运行时依赖 @nestjs/jwt、argon2(计划 A1-BE-02 已批准,版本精确锁定)。 - 迁移为 expand,不改既有表;本地需 prisma migrate 后重新 seed。 - 平台导航「用户与组织」由 /platform/users 调整为 /users。 回滚方式: - 代码整体回滚本提交;迁移为 expand,回滚代码不需删表; - 本地如需彻底回退按实施报告 §6 处理。 验证证据: - pnpm format:check / lint / typecheck 通过; - pnpm test:shared 95 / api 60 / web 55; - pnpm test:int:7 个(真实 PG/Redis); - A1_E2E=1 playwright test e2e/a1-identity.spec.ts:6/6; - 报告:docs/开发计划/灵犀_A1身份认证与用户管理_实施报告_V0.1.md
This commit is contained in:
1 parent
f0d218bd99
commit
4d9eb980af
120 files changed
+13112
-314
No files matched your search
@@ -1,6 +1,310 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"paths": {
|
||||
"/api/v1/auth/login": {
|
||||
"post": {
|
||||
"description": "返回 accessToken / refreshToken / expiresIn / me",
|
||||
"operationId": "AuthController_login",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"summary": "账号密码登录",
|
||||
"tags": [
|
||||
"identity-auth"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/auth/refresh": {
|
||||
"post": {
|
||||
"operationId": "AuthController_refresh",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"summary": "刷新令牌(旋转,旧 refresh 立即失效)",
|
||||
"tags": [
|
||||
"identity-auth"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/auth/logout": {
|
||||
"post": {
|
||||
"description": "吊销 refresh 令牌所在家族",
|
||||
"operationId": "AuthController_logout",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"summary": "登出",
|
||||
"tags": [
|
||||
"identity-auth"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/auth/change-password": {
|
||||
"post": {
|
||||
"operationId": "AuthController_changePassword",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"summary": "修改密码(首登强改)",
|
||||
"tags": [
|
||||
"identity-auth"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/me": {
|
||||
"get": {
|
||||
"operationId": "MeController_current",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "当前用户、角色、权限点、数据范围",
|
||||
"tags": [
|
||||
"identity-me"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/users": {
|
||||
"get": {
|
||||
"description": "status 默认 active(停用默认隐藏);sort/order 走白名单;手机号仅返回掩码",
|
||||
"operationId": "UsersController_list",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "用户列表(游标分页)",
|
||||
"tags": [
|
||||
"identity-users"
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"description": "初始密码由管理员设定,首登强制修改",
|
||||
"operationId": "UsersController_create",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "新建用户",
|
||||
"tags": [
|
||||
"identity-users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/users/{id}": {
|
||||
"get": {
|
||||
"description": "仅 user:manage 返回 phone 全号",
|
||||
"operationId": "UsersController_detail",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "用户详情",
|
||||
"tags": [
|
||||
"identity-users"
|
||||
]
|
||||
},
|
||||
"patch": {
|
||||
"operationId": "UsersController_update",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "更新用户(不含账号 / 状态 / 密码)",
|
||||
"tags": [
|
||||
"identity-users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/users/{id}/disable": {
|
||||
"post": {
|
||||
"description": "停用后旧令牌立即失效;可指定客户转交人",
|
||||
"operationId": "UsersController_disable",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "停用用户",
|
||||
"tags": [
|
||||
"identity-users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/users/{id}/enable": {
|
||||
"post": {
|
||||
"operationId": "UsersController_enable",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "启用用户",
|
||||
"tags": [
|
||||
"identity-users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/users/{id}/transfer-customers": {
|
||||
"post": {
|
||||
"description": "A3 客户模块落地前返回 42201",
|
||||
"operationId": "UsersController_transferCustomers",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "客户转交(占位)",
|
||||
"tags": [
|
||||
"identity-users"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/departments/tree": {
|
||||
"get": {
|
||||
"operationId": "DepartmentsController_tree",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "部门树(两级,含成员数与负责人)",
|
||||
"tags": [
|
||||
"identity-departments"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/departments": {
|
||||
"post": {
|
||||
"description": "最多两级,在小组下新建返回 42201",
|
||||
"operationId": "DepartmentsController_create",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "新建部门 / 小组",
|
||||
"tags": [
|
||||
"identity-departments"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/departments/{id}": {
|
||||
"patch": {
|
||||
"operationId": "DepartmentsController_rename",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "部门改名",
|
||||
"tags": [
|
||||
"identity-departments"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v1/roles": {
|
||||
"get": {
|
||||
"operationId": "RolesController_list",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
}
|
||||
],
|
||||
"summary": "角色列表(绑定用)",
|
||||
"tags": [
|
||||
"identity-roles"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/health": {
|
||||
"get": {
|
||||
"description": "真实检查 PostgreSQL 与 Redis;任一不可用返回 503 与统一错误体。",
|
||||
|
||||
Reference in new issue
Block a user