Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
116318df74 | ||
|
|
bdb9a5b474 | ||
|
|
a92e4da043 | ||
|
|
bc1a01848d | ||
|
|
0bbdb27f6d | ||
|
|
40409707cc |
@@ -7,9 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/config"
|
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/captcha"
|
|
||||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
||||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
"github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||||
@@ -82,21 +80,13 @@ func Authenticator(c *gin.Context) (interface{}, error) {
|
|||||||
|
|
||||||
return nil, jwt.ErrMissingLoginValues
|
return nil, jwt.ErrMissingLoginValues
|
||||||
}
|
}
|
||||||
if config.ApplicationConfig.Mode != "dev" {
|
|
||||||
if !captcha.Verify(loginVals.UUID, loginVals.Code, true) {
|
|
||||||
username = loginVals.Username
|
|
||||||
msg = "验证码错误"
|
|
||||||
status = "1"
|
|
||||||
|
|
||||||
return nil, jwt.ErrInvalidVerificationode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sysUser, role, e := loginVals.GetUser(db)
|
sysUser, role, e := loginVals.GetUser(db)
|
||||||
if e == nil {
|
if e == nil {
|
||||||
username = loginVals.Username
|
username = loginVals.Username
|
||||||
|
|
||||||
return map[string]interface{}{"user": sysUser, "role": role}, nil
|
return map[string]interface{}{"user": sysUser, "role": role}, nil
|
||||||
} else {
|
} else {
|
||||||
|
username = loginVals.Username
|
||||||
msg = "登录失败"
|
msg = "登录失败"
|
||||||
status = "1"
|
status = "1"
|
||||||
log.Warnf("%s login failed!", loginVals.Username)
|
log.Warnf("%s login failed!", loginVals.Username)
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import (
|
|||||||
type Login struct {
|
type Login struct {
|
||||||
Username string `form:"UserName" json:"username" binding:"required"`
|
Username string `form:"UserName" json:"username" binding:"required"`
|
||||||
Password string `form:"Password" json:"password" binding:"required"`
|
Password string `form:"Password" json:"password" binding:"required"`
|
||||||
Code string `form:"Code" json:"code" binding:"required"`
|
|
||||||
UUID string `form:"UUID" json:"uuid" binding:"required"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Login) GetUser(tx *gorm.DB) (user SysUser, role SysRole, err error) {
|
func (u *Login) GetUser(tx *gorm.DB) (user SysUser, role SysRole, err error) {
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http/httptest"
|
||||||
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLoginAcceptsCredentialsWithoutCaptcha(t *testing.T) {
|
||||||
|
gin.SetMode(gin.TestMode)
|
||||||
|
ctx, _ := gin.CreateTestContext(httptest.NewRecorder())
|
||||||
|
ctx.Request = httptest.NewRequest("POST", "/api/v1/login", strings.NewReader(`{"username":"operator","password":"valid-password"}`))
|
||||||
|
ctx.Request.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
var login Login
|
||||||
|
if err := ctx.ShouldBindJSON(&login); err != nil {
|
||||||
|
t.Fatalf("bind credentials-only login: %v", err)
|
||||||
|
}
|
||||||
|
if login.Username != "operator" || login.Password != "valid-password" {
|
||||||
|
t.Fatalf("unexpected login payload: username=%q", login.Username)
|
||||||
|
}
|
||||||
|
|
||||||
|
typeOfLogin := reflect.TypeOf(login)
|
||||||
|
if typeOfLogin.NumField() != 2 {
|
||||||
|
t.Fatalf("login payload must only expose username and password, got %d fields", typeOfLogin.NumField())
|
||||||
|
}
|
||||||
|
for _, removed := range []string{"Code", "UUID"} {
|
||||||
|
if _, ok := typeOfLogin.FieldByName(removed); ok {
|
||||||
|
t.Fatalf("captcha field %s must not be part of the login payload", removed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3798,23 +3798,15 @@ const docTemplateadmin = `{
|
|||||||
"handler.Login": {
|
"handler.Login": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"code",
|
|
||||||
"password",
|
"password",
|
||||||
"username",
|
"username"
|
||||||
"uuid"
|
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"password": {
|
"password": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"username": {
|
"username": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
|
||||||
"uuid": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3789,23 +3789,15 @@
|
|||||||
"handler.Login": {
|
"handler.Login": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"code",
|
|
||||||
"password",
|
"password",
|
||||||
"username",
|
"username"
|
||||||
"uuid"
|
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"password": {
|
"password": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"username": {
|
"username": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
|
||||||
"uuid": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -685,19 +685,13 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
handler.Login:
|
handler.Login:
|
||||||
properties:
|
properties:
|
||||||
code:
|
|
||||||
type: string
|
|
||||||
password:
|
password:
|
||||||
type: string
|
type: string
|
||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
uuid:
|
|
||||||
type: string
|
|
||||||
required:
|
required:
|
||||||
- code
|
|
||||||
- password
|
- password
|
||||||
- username
|
- username
|
||||||
- uuid
|
|
||||||
type: object
|
type: object
|
||||||
models.SysApi:
|
models.SysApi:
|
||||||
properties:
|
properties:
|
||||||
|
|||||||
@@ -102,29 +102,6 @@
|
|||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="验证码" prop="code">
|
|
||||||
<div class="captcha-row">
|
|
||||||
<el-input
|
|
||||||
v-model="loginForm.code"
|
|
||||||
placeholder="请输入验证码"
|
|
||||||
name="code"
|
|
||||||
type="text"
|
|
||||||
tabindex="3"
|
|
||||||
maxlength="5"
|
|
||||||
autocomplete="off"
|
|
||||||
size="large"
|
|
||||||
:prefix-icon="Key"
|
|
||||||
@keyup.enter="handleLogin"
|
|
||||||
/>
|
|
||||||
<div class="captcha-wrap" title="点击刷新" @click="getCode">
|
|
||||||
<img v-if="codeUrl" :src="codeUrl" class="captcha-img" alt="验证码">
|
|
||||||
<div v-else class="captcha-placeholder">
|
|
||||||
<el-icon class="is-loading"><Loading /></el-icon>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-button
|
<el-button
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -142,27 +119,22 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getCodeImg } from '@/api/login'
|
import { User, Lock, View, Hide, Monitor } from '@element-plus/icons-vue'
|
||||||
import { User, Lock, Key, View, Hide, Monitor, Loading } from '@element-plus/icons-vue'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'LoginPage',
|
name: 'LoginPage',
|
||||||
setup() {
|
setup() {
|
||||||
return { User, Lock, Key, View, Hide, Monitor, Loading }
|
return { User, Lock, View, Hide, Monitor }
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
codeUrl: '',
|
|
||||||
loginForm: {
|
loginForm: {
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: ''
|
||||||
code: '',
|
|
||||||
uuid: ''
|
|
||||||
},
|
},
|
||||||
loginRules: {
|
loginRules: {
|
||||||
username: [{ required: true, trigger: 'blur', message: '用户名不能为空' }],
|
username: [{ required: true, trigger: 'blur', message: '用户名不能为空' }],
|
||||||
password: [{ required: true, trigger: 'blur', message: '密码不能为空' }],
|
password: [{ required: true, trigger: 'blur', message: '密码不能为空' }]
|
||||||
code: [{ required: true, trigger: 'change', message: '验证码不能为空' }]
|
|
||||||
},
|
},
|
||||||
passwordType: 'password',
|
passwordType: 'password',
|
||||||
capsTooltip: false,
|
capsTooltip: false,
|
||||||
@@ -185,7 +157,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getCode()
|
|
||||||
this.getSystemSetting()
|
this.getSystemSetting()
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -202,15 +173,6 @@ export default {
|
|||||||
document.title = ret.sys_app_name
|
document.title = ret.sys_app_name
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getCode() {
|
|
||||||
this.codeUrl = ''
|
|
||||||
getCodeImg().then((res) => {
|
|
||||||
if (res !== undefined) {
|
|
||||||
this.codeUrl = res.data
|
|
||||||
this.loginForm.uuid = res.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
checkCapslock({ shiftKey, key } = {}) {
|
checkCapslock({ shiftKey, key } = {}) {
|
||||||
if (key && key.length === 1) {
|
if (key && key.length === 1) {
|
||||||
if ((shiftKey && key >= 'a' && key <= 'z') || (!shiftKey && key >= 'A' && key <= 'Z')) {
|
if ((shiftKey && key >= 'a' && key <= 'z') || (!shiftKey && key >= 'A' && key <= 'Z')) {
|
||||||
@@ -238,7 +200,6 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.getCode()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -562,48 +523,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── 验证码 ── */
|
|
||||||
.captcha-row {
|
|
||||||
display: flex;
|
|
||||||
gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.el-input {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.captcha-wrap {
|
|
||||||
width: 110px;
|
|
||||||
height: 40px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
border-radius: 8px;
|
|
||||||
border: 1px solid #e5e7eb;
|
|
||||||
overflow: hidden;
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: #f9fafb;
|
|
||||||
transition: border-color 0.2s;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: #3b82f6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.captcha-img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.captcha-placeholder {
|
|
||||||
color: #c1c7d0;
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── 登录按钮 ── */
|
/* ── 登录按钮 ── */
|
||||||
.submit-btn {
|
.submit-btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import LoginPage from '@/views/login/index.vue'
|
||||||
|
|
||||||
|
describe('Sense login page', () => {
|
||||||
|
it('uses username and password without a captcha challenge', () => {
|
||||||
|
const state = LoginPage.data()
|
||||||
|
const getSystemSetting = jest.fn()
|
||||||
|
|
||||||
|
LoginPage.created.call({ getSystemSetting })
|
||||||
|
|
||||||
|
expect(Object.keys(state.loginForm)).toEqual(['username', 'password'])
|
||||||
|
expect(Object.keys(state.loginRules)).toEqual(['username', 'password'])
|
||||||
|
expect(LoginPage.methods.getCode).toBeUndefined()
|
||||||
|
expect(getSystemSetting).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
generated: true (请先修改 Gitea Wiki,禁止直接编辑本文件)
|
generated: true (请先修改 Gitea Wiki,禁止直接编辑本文件)
|
||||||
wiki_page: Local-Development-and-Verification
|
wiki_page: Local-Development-and-Verification
|
||||||
wiki_url: https://git.ilapage.cn/ila/yovision/wiki/Local-Development-and-Verification.-
|
wiki_url: https://git.ilapage.cn/ila/yovision/wiki/Local-Development-and-Verification.-
|
||||||
wiki_revision: 31cad04ab68ee653f2ec3ca6d7297a6bef768f54
|
wiki_revision: ee4819a84dd40846bc8fe1865e08590e1cf9cb81
|
||||||
synchronized_at: 2026-08-15T01:13:07Z
|
synchronized_at: 2026-08-15T09:58:37Z
|
||||||
<!-- gitea-wiki-mirror:end -->
|
<!-- gitea-wiki-mirror:end -->
|
||||||
|
|
||||||
# 本地开发与验证
|
# 本地开发与验证
|
||||||
@@ -146,7 +146,7 @@ Invoke-RestMethod -Method Post -Uri "http://127.0.0.1:<端口>/api/v1/bootstrap"
|
|||||||
Remove-Variable bootstrapToken, bootstrapBody
|
Remove-Variable bootstrapToken, bootstrapBody
|
||||||
```
|
```
|
||||||
|
|
||||||
初始化成功后停止服务,从启动环境中执行 `Remove-Item Env:SENSE_BOOTSTRAP_TOKEN`,再按正常生产方式启动。已有任一用户时初始化接口会拒绝请求。生产登录需要先调用验证码接口并提交验证码;自动化集成验证不得通过关闭生产安全约束来冒充生产结果。
|
初始化成功后停止服务,从启动环境中执行 `Remove-Item Env:SENSE_BOOTSTRAP_TOKEN`,再按正常生产方式启动。已有任一用户时初始化接口会拒绝请求。Sense 在 production、test、dev 模式均只提交账号和密码,不显示、不请求也不校验验证码;`/api/v1/captcha` 暂时保留作上游兼容接口,但登录页和登录 API 不依赖它。登录成功、错误密码和未认证拒绝仍必须写入脱敏身份审计,密码继续执行 6–72 字节策略。
|
||||||
|
|
||||||
身份回归至少覆盖:admin 可管理账户及查看审计;implementation_operator 只能查看实施所需日志和字典支撑数据;site_admin 可维护账户并读取角色、部门、岗位、字典,但不能修改角色或菜单;viewer 不能访问管理接口。还要验证配置/接口管理路由返回 404、短密码被拒绝、6 位全小写密码可用,以及登录/登出/改密/拒绝审计中不含密码、令牌、Cookie 或验证码。身份审计直接写入 PostgreSQL,不依赖通用操作日志数据库开关。
|
身份回归至少覆盖:admin 可管理账户及查看审计;implementation_operator 只能查看实施所需日志和字典支撑数据;site_admin 可维护账户并读取角色、部门、岗位、字典,但不能修改角色或菜单;viewer 不能访问管理接口。还要验证配置/接口管理路由返回 404、短密码被拒绝、6 位全小写密码可用,以及登录/登出/改密/拒绝审计中不含密码、令牌、Cookie 或验证码。身份审计直接写入 PostgreSQL,不依赖通用操作日志数据库开关。
|
||||||
|
|
||||||
@@ -230,9 +230,38 @@ corepack pnpm@9.15.1 build:prod
|
|||||||
<!-- bell-runtime:end -->
|
<!-- bell-runtime:end -->
|
||||||
|
|
||||||
<!-- sense-windows-package:start -->
|
<!-- sense-windows-package:start -->
|
||||||
## Sense Windows 打包状态
|
## Sense Windows 打包与验证
|
||||||
|
|
||||||
旧 Sense Windows 包脚本只属于 `explore` 快照。新的打包命令必须在 GoAdmin 派生骨架和业务迁移完成后由独立工单重新建立、验证和记录。
|
在仓库根目录使用冻结工具链构建:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Sense\scripts\build\build-windows.ps1 -MediaMTXPath D:\approved\mediamtx.exe
|
||||||
|
```
|
||||||
|
|
||||||
|
构建脚本严格检查 Go 1.26.5、Node 22.22.1 和 pnpm 9.15.1,执行前端生产构建与 Windows 后端构建,并生成 `Sense\dist\sense-windows-amd64\` 和同名 ZIP。未传 `-MediaMTXPath` 时只生成占位说明,交付前必须另外提供已审核的 Windows amd64 MediaMTX。构建末尾会执行包审计,并清理源码目录的 `Sense/ui/node_modules` 与 `Sense/ui/dist`。
|
||||||
|
|
||||||
|
提交前验证:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
cd Sense\server
|
||||||
|
go test ./...
|
||||||
|
go vet ./...
|
||||||
|
go build ./...
|
||||||
|
go test -race ./app/sense/media ./cmd/api
|
||||||
|
|
||||||
|
cd ..\..
|
||||||
|
Sense\scripts\build\test-package.ps1 -PackageRoot Sense\dist\sense-windows-amd64
|
||||||
|
```
|
||||||
|
|
||||||
|
包内验证从解压目录执行:
|
||||||
|
|
||||||
|
```bat
|
||||||
|
check-sense.bat
|
||||||
|
start-sense.bat
|
||||||
|
stop-sense.bat
|
||||||
|
```
|
||||||
|
|
||||||
|
检查项至少覆盖配置解析与进程环境优先级、特殊字符不被执行、production/demo 数据库隔离、迁移失败不启动服务、首页 SPA fallback、`/healthz`、MediaMTX Control API、包外工作目录启动与停止、PostgreSQL custom-format 备份及恢复到独立数据库。真实摄像机、目标客户数据库账号、目标浏览器与干净客户机器仍须在授权交付环境验收。
|
||||||
<!-- sense-windows-package:end -->
|
<!-- sense-windows-package:end -->
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
generated: true (请先修改 Gitea Wiki,禁止直接编辑本文件)
|
generated: true (请先修改 Gitea Wiki,禁止直接编辑本文件)
|
||||||
wiki_page: Product-Requirements
|
wiki_page: Product-Requirements
|
||||||
wiki_url: https://git.ilapage.cn/ila/yovision/wiki/Product-Requirements.-
|
wiki_url: https://git.ilapage.cn/ila/yovision/wiki/Product-Requirements.-
|
||||||
wiki_revision: f0d16a60406eed6fd6968c6555c599554bbd1fae
|
wiki_revision: 221fd392c943caab13ee097c19a3d19d4410b65a
|
||||||
synchronized_at: 2026-08-11T10:30:56Z
|
synchronized_at: 2026-08-15T09:59:15Z
|
||||||
<!-- gitea-wiki-mirror:end -->
|
<!-- gitea-wiki-mirror:end -->
|
||||||
|
|
||||||
# 产品需求
|
# 产品需求
|
||||||
@@ -48,7 +48,7 @@ YoVision 首个可交付目标是在民办寄宿学校以默认 16 路高风险
|
|||||||
|
|
||||||
### P0
|
### P0
|
||||||
|
|
||||||
- **SEN-001 独立登录与权限**:Sense 自有用户、角色、菜单、会话和审计;至少覆盖管理员、实施/运维、站点管理员和只读边界。
|
- **SEN-001 独立登录与权限**:Sense 自有用户、角色、菜单、会话和审计;至少覆盖管理员、实施/运维、站点管理员和只读边界。首期采用账号密码直接登录,所有运行模式均不使用验证码;密码保持 6–72 字节且不强制字符复杂度,登录成功与失败必须记录不含秘密的身份审计。
|
||||||
- **SEN-002 设备台账**:以 Device 为根实体,通过 `modality` 和 `capabilities` 表达 video/radar/contact/button/wearable/other;首期只完整实现 video,未实现适配器显示 `adapter_not_ready`。
|
- **SEN-002 设备台账**:以 Device 为根实体,通过 `modality` 和 `capabilities` 表达 video/radar/contact/button/wearable/other;首期只完整实现 video,未实现适配器显示 `adapter_not_ready`。
|
||||||
- **SEN-003 ONVIF/RTSP 接入**:支持发现或手工添加、Profiles、StreamUri、主/子码流、校时、认证失败、重新探测和凭据更新。
|
- **SEN-003 ONVIF/RTSP 接入**:支持发现或手工添加、Profiles、StreamUri、主/子码流、校时、认证失败、重新探测和凭据更新。
|
||||||
- **SEN-004 批量开通**:默认 16 路可导入、预校验、待激活、逐项成功/失败、仅重试失败项;部分成功不做整体回滚。
|
- **SEN-004 批量开通**:默认 16 路可导入、预校验、待激活、逐项成功/失败、仅重试失败项;部分成功不做整体回滚。
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
<!-- gitea-wiki-mirror:start -->
|
||||||
|
generated: true (请先修改 Gitea Wiki,禁止直接编辑本文件)
|
||||||
|
wiki_page: Task-97-Sense免验证码登录与管理员密码重置
|
||||||
|
wiki_url: https://git.ilapage.cn/ila/yovision/wiki/Task-97-Sense%E5%85%8D%E9%AA%8C%E8%AF%81%E7%A0%81%E7%99%BB%E5%BD%95%E4%B8%8E%E7%AE%A1%E7%90%86%E5%91%98%E5%AF%86%E7%A0%81%E9%87%8D%E7%BD%AE.-
|
||||||
|
wiki_revision: 486ebcca10e4cef0bd905df59b928c17006db17e
|
||||||
|
synchronized_at: 2026-08-16T11:04:57Z
|
||||||
|
<!-- gitea-wiki-mirror:end -->
|
||||||
|
|
||||||
|
# 97 Sense免验证码登录与管理员密码重置
|
||||||
|
|
||||||
|
- 类型:安全行为调整 / 缺陷修复
|
||||||
|
- 所属 Epic:#7
|
||||||
|
- 所属 MVP / 版本:#8
|
||||||
|
- 状态:已完成
|
||||||
|
- 日期:2026-08-15
|
||||||
|
- Gitea 工单:https://git.ilapage.cn/ila/yovision/issues/97
|
||||||
|
- Wiki 页面:Task-97-Sense免验证码登录与管理员密码重置
|
||||||
|
- Wiki revision:见本地镜像头
|
||||||
|
|
||||||
|
## 背景与目标
|
||||||
|
|
||||||
|
GoAdmin 重建后的 Sense 登录页和生产后端重新启用了验证码,与用户确认的账号密码直接登录流程不一致。用户要求所有运行模式恢复免验证码登录,并把当前本地 PostgreSQL 的管理员账号设置为用户指定、满足现行 6–72 字节策略的密码;密码明文不得进入仓库、工单、Wiki 或日志。
|
||||||
|
|
||||||
|
## 最终方案
|
||||||
|
|
||||||
|
- 保留冻结 GoAdmin 的 Gin/GORM/JWT/Casbin `Authenticator`、登录路由、Vuex 登录动作、Element Plus 表单和同步身份审计。
|
||||||
|
- 登录 DTO 只保留 `username/password`;production、test、dev 均不再校验验证码。
|
||||||
|
- 登录页移除验证码字段、规则、图标、接口请求、失败刷新和样式;兼容保留 `/api/v1/captcha` 端点及上游存储初始化,便于回退。
|
||||||
|
- Swagger 登录载荷同步为只要求账号和密码。
|
||||||
|
- 修复失败认证分支未把用户名写入审计的问题,使错误密码尝试可按账号追踪。
|
||||||
|
- 目标数据库起初没有任何用户,因此没有执行不安全的直接插入;使用一次性高熵进程令牌走既有 `/api/v1/bootstrap` 安全初始化路径创建 `admin`,密码只在进程内传递。随后验证正确密码成功、错误密码拒绝和成功/失败审计。
|
||||||
|
- 密码最少 6 位、最多 72 字节且不强制字符复杂度的既有策略保持不变;JWT、RBAC、Cookie 和会话有效期未修改。
|
||||||
|
|
||||||
|
## 修改文件
|
||||||
|
|
||||||
|
- `Sense/server/common/middleware/handler/auth.go`:移除验证码校验并补齐失败登录用户名审计。
|
||||||
|
- `Sense/server/common/middleware/handler/login.go`:登录载荷只保留账号和密码。
|
||||||
|
- `Sense/server/common/middleware/handler/login_test.go`:覆盖无验证码登录载荷。
|
||||||
|
- `Sense/server/docs/admin/admin_docs.go`、`admin_swagger.json`、`admin_swagger.yaml`:同步登录接口模型。
|
||||||
|
- `Sense/ui/src/views/login/index.vue`:移除验证码 UI、请求和状态。
|
||||||
|
- `Sense/ui/tests/unit/login/loginPage.spec.js`:覆盖登录页只使用账号密码。
|
||||||
|
- Wiki `Product-Requirements`、`Local-Development-and-Verification` 及镜像:记录免验证码登录、安全审计和密码策略边界。
|
||||||
|
|
||||||
|
## 验收结果
|
||||||
|
|
||||||
|
| 验收标准 | 结果 |
|
||||||
|
|---|---|
|
||||||
|
| 登录页不显示验证码且不请求验证码接口 | 通过:组件状态、规则与方法均只含账号密码;生产构建通过 |
|
||||||
|
| 所有模式接受仅账号密码的登录载荷 | 通过:后端不再按模式进入 captcha 校验,DTO 定向测试通过 |
|
||||||
|
| 正确密码成功、错误密码拒绝并有脱敏审计 | 通过:本地 production/PostgreSQL smoke 成功;成功与失败审计均可按 admin 查询 |
|
||||||
|
| JWT、RBAC、未登录拒绝不变 | 通过:未认证管理路由返回 401,全量后端测试通过 |
|
||||||
|
| 密码策略仍为 6–72 字节 | 通过:现有密码策略测试通过,相关代码未修改 |
|
||||||
|
| 管理员密码安全设置且仓库无明文 | 通过:空用户库经一次性 bootstrap 创建,跟踪差异秘密扫描无泄漏 |
|
||||||
|
| 前后端测试和 production build | 通过 |
|
||||||
|
|
||||||
|
## 测试
|
||||||
|
|
||||||
|
- `go test ./...`:通过。
|
||||||
|
- `go vet ./...`:通过。
|
||||||
|
- `go build ./...`:通过。
|
||||||
|
- `corepack pnpm@9.15.1 exec eslint src/views/login/index.vue tests/unit/login/loginPage.spec.js`:通过。
|
||||||
|
- 前端全量单测:17 个 suite、46 个 test 通过。
|
||||||
|
- `corepack pnpm@9.15.1 run build:prod`:通过;存在既有 Sass、SCSS export、代码生成器和体积 warning,未由本工单引入。
|
||||||
|
- production/PostgreSQL/MediaMTX smoke:安全初始化成功、免验证码登录成功、错误密码拒绝、未认证接口返回 401;身份审计包含首个管理员创建、登录成功和登录失败记录。
|
||||||
|
- `python -m unittest discover -s tests -v`:31 项通过。
|
||||||
|
- `python dev_scripts/check_harness.py --strict`:只因既有 #66/#67 归档缺少当前模板章节失败 4 项,与本工单修改无关。
|
||||||
|
- `git diff --check` 与跟踪差异密码扫描:通过。
|
||||||
|
- 测试结束后 Sense、MediaMTX 均已停止,18080/9997 无监听;`Sense/ui/node_modules` 与 `Sense/ui/dist` 已清理。
|
||||||
|
- **未验证部分**:尚未在 #70 最终 Windows ZIP、客户全新 Windows 主机和客户目标浏览器中重新打包验收;#70 与 #97 合入 `dev` 后需重新生成发布包。
|
||||||
|
|
||||||
|
## 遗留问题
|
||||||
|
|
||||||
|
- 验证码 API 为上游兼容而保留但登录链不使用;若未来永久删除,需单独清理工单核对依赖和回退。
|
||||||
|
- 取消验证码降低自动化暴力尝试阻力;本工单按用户确认保留失败登录审计,但未引入未确认的限流或锁定体系。
|
||||||
|
|
||||||
|
## 相关提交
|
||||||
|
|
||||||
|
- `0bbdb27f6db4f9d08445ca02abae9061c81598b8` 恢复免验证码登录并补充测试。
|
||||||
|
- `bc1a01848d1769250b706f207d542b63fee2afa6` 更新 Sense 登录安全边界镜像。
|
||||||
|
|
||||||
|
|
||||||
|
## 人工验收
|
||||||
|
|
||||||
|
- 2026-08-16:用户明确验收通过 #97。
|
||||||
|
- 按工作流将 PR #98 合入 `dev`;`main` 保持不变。
|
||||||
@@ -131,6 +131,10 @@
|
|||||||
{
|
{
|
||||||
"page": "Task-69-Sense多边形区域与方向警戒线配置",
|
"page": "Task-69-Sense多边形区域与方向警戒线配置",
|
||||||
"path": "docs/task/69-Sense多边形区域与方向警戒线配置.md"
|
"path": "docs/task/69-Sense多边形区域与方向警戒线配置.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"page": "Task-97-Sense免验证码登录与管理员密码重置",
|
||||||
|
"path": "docs/task/97-Sense免验证码登录与管理员密码重置.md"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user