server: Go 服务器(REST+WSS 网关+JWT+Argon2+配对+素材直链+任务状态机);修复并发下线 send-on-closed-channel、下发查询 SQL 优先级、配对码原子占用、上传体积上限、JWT 默认密钥告警

This commit is contained in:
Qiufeng
2026-08-20 20:38:21 +08:00
parent bf25d8beac
commit cc8845dcec
44 changed files with 4995 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package cache
import (
"context"
"fmt"
"time"
)
// SaveRefresh 登记刷新令牌(jti 白名单,用于轮换与登出吊销)
func (r *Redis) SaveRefresh(uid uint64, jti string, ttl time.Duration) error {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
key := fmt.Sprintf("refresh:%d:%s", uid, jti)
return r.client.Set(ctx, key, "1", ttl).Err()
}
// ExistsRefresh 校验刷新令牌是否有效
func (r *Redis) ExistsRefresh(uid uint64, jti string) (bool, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
key := fmt.Sprintf("refresh:%d:%s", uid, jti)
n, err := r.client.Exists(ctx, key).Result()
return n == 1, err
}
// DeleteRefresh 吊销刷新令牌
func (r *Redis) DeleteRefresh(uid uint64, jti string) error {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
key := fmt.Sprintf("refresh:%d:%s", uid, jti)
return r.client.Del(ctx, key).Err()
}