feat: 实现工位终端滑动续签机制,强化安全与身份追溯
- 新增滑动续签功能:人工触屏触发本地心跳 + 30秒节流刷新JWT,避免作业中令牌过期 - 拆分质量检验权限:过程检/完工检使用不同权限码,细化权限粒度 - 新增操作人用户ID字段:报工、拧紧记录落库时携带可信用户ID,解决身份追溯问题 - 移除编译期默认密钥,启动期校验所有必要密钥非空,防止密钥泄露风险 - 修复WMS附件越权遍历问题:使用UUID文件名替代顺序ID访问附件 - 实现登录态过期数据隔离:仅返回当前操作人的待同步数据,避免身份混淆
This commit is contained in:
@@ -252,6 +252,31 @@ func (s *Service) StationLogin(ctx context.Context, req StationLoginReq) (Statio
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// StationRefreshTokenResp 工位终端滑动续签响应
|
||||
type StationRefreshTokenResp struct {
|
||||
AccessToken string `json:"accessToken"`
|
||||
ExpireAt int64 `json:"expireAt"`
|
||||
}
|
||||
|
||||
// StationRefreshToken 工位终端滑动续签:校验当前登录态 JWT 有效后,原样重签新 JWT(延长有效期)。
|
||||
// 终端任何人工触屏经前端 30 秒节流后调用,作业中令牌不再因固定有效期过期而被登出。
|
||||
// 工位终端与 MES 同密钥,claims(含 StationNo)原样保留。
|
||||
func (s *Service) StationRefreshToken(tokenStr string) (StationRefreshTokenResp, error) {
|
||||
var resp StationRefreshTokenResp
|
||||
claims, err := tokenx.Parse(s.ctx.Config.Auth.AccessSecret, tokenStr)
|
||||
if err != nil || claims == nil {
|
||||
return resp, errors.New("登录凭证无效或已过期,请重新登录")
|
||||
}
|
||||
expire := s.sessionExpire()
|
||||
access, err := tokenx.Issue(s.ctx.Config.Auth.AccessSecret, time.Duration(expire)*time.Second, *claims)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
resp.AccessToken = access
|
||||
resp.ExpireAt = time.Now().Add(time.Duration(expire) * time.Second).Unix()
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// StationChangePassword 工位终端修改自己的工位终端密码
|
||||
func (s *Service) StationChangePassword(ctx context.Context, userId int, oldPwd, newPwd string) error {
|
||||
if userId <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user