fix(api): reject invalid UUID variants

This commit is contained in:
2026-07-21 14:02:31 +08:00
parent 7803b2faf0
commit 4bfeec8d2b
2 changed files with 2 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ import (
// IdentityParam 只接受 UUIDv7 路径参数,避免把内部自增 ID 暴露为外部标识。
func IdentityParam(c *gin.Context, name string) (string, bool) {
identity, err := uuid.Parse(c.Param(name))
if err != nil || identity.Version() != 7 {
if err != nil || identity.Version() != 7 || identity.Variant() != uuid.RFC4122 {
Error(c, http.StatusBadRequest, "invalid_request", "请求参数无效")
return "", false
}