sync: 同步 v1.0.4 并脱敏配置与镜像
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// package system
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <xxx@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package system
|
||||
|
||||
@@ -195,7 +195,7 @@ func (s *sSysAuth) GenerateToken(ctx context.Context, user *model.LoginUserOut)
|
||||
ets := g.Cfg().MustGet(ctx, "jwt.expiresTime", "7d").String()
|
||||
bts := g.Cfg().MustGet(ctx, "jwt.bufferTime", "1d").String()
|
||||
iss := g.Cfg().MustGet(ctx, "jwt.issuer", "IotLCM").String()
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "${JWT_SIGNING_KEY}").String()
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "39c54195e73304e74a8429b178965865").String()
|
||||
et, _ := utility.ParseDuration(ets)
|
||||
bt, _ := utility.ParseDuration(bts)
|
||||
g.Log().Infof(ctx, "sSysAuth.GenerateToken 生成Token: user:%+v, et:%s, bt:%s, iss:%s, sk:%s", user, et, bt, iss, sk)
|
||||
@@ -265,7 +265,7 @@ func (s *sSysAuth) GenerateToken(ctx context.Context, user *model.LoginUserOut)
|
||||
|
||||
// 解析Token
|
||||
func (s *sSysAuth) ParseToken(ctx context.Context, token string) (claims *model.CustomClaims, err error) {
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "${JWT_SIGNING_KEY}").String()
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "39c54195e73304e74a8429b178965865").String()
|
||||
t, err := jwt.ParseWithClaims(token, &model.CustomClaims{}, func(token *jwt.Token) (interface{}, error) {
|
||||
return []byte(sk), nil
|
||||
})
|
||||
@@ -287,7 +287,7 @@ func (s *sSysAuth) ParseToken(ctx context.Context, token string) (claims *model.
|
||||
|
||||
// 删除Token
|
||||
func (s *sSysAuth) DeleteToken(ctx context.Context, token string) (err error) {
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "${JWT_SIGNING_KEY}").String()
|
||||
sk := g.Cfg().MustGet(ctx, "jwt.signingKey", "39c54195e73304e74a8429b178965865").String()
|
||||
t, err := jwt.ParseWithClaims(token, &model.CustomClaims{}, func(token *jwt.Token) (interface{}, error) {
|
||||
return []byte(sk), nil
|
||||
})
|
||||
@@ -341,11 +341,6 @@ func (s *sSysAuth) GetUserAccessCodeList(ctx context.Context, userId int64) (acc
|
||||
accessCodeList = make([]string, 0)
|
||||
menuRoleAccessCodeList = make([]string, 0)
|
||||
roleDataScopeMap := make(map[int64]string)
|
||||
template, templateErr := rolepolicy.Template(ctx)
|
||||
if templateErr != nil {
|
||||
return nil, nil, templateErr
|
||||
}
|
||||
managed := template != nil && template.TenantId == contexts.GetTenantId(ctx) && template.DeptId != contexts.GetDeptId(ctx)
|
||||
// 角色权限码
|
||||
roleIds, err := service.SysUser().GetUserRoleIds(ctx, userId)
|
||||
if err != nil {
|
||||
@@ -353,14 +348,28 @@ func (s *sSysAuth) GetUserAccessCodeList(ctx context.Context, userId int64) (acc
|
||||
}
|
||||
var effectiveRoles []*entity.SysRole
|
||||
if len(roleIds) > 0 {
|
||||
if err := dao.SysRole.Ctx(ctx).Where("tenant_id", contexts.GetTenantId(ctx)).WhereIn("role_id", roleIds).Where("status", "0").Scan(&effectiveRoles); err != nil {
|
||||
if err := dao.SysRole.Ctx(ctx).Master().Where("tenant_id", contexts.GetTenantId(ctx)).WhereIn("role_id", roleIds).Where("status", "0").Scan(&effectiveRoles); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
roleIds = nil
|
||||
if contexts.GetTenantId(ctx) != consts.DefaultSystemTenantCode {
|
||||
effectiveRoles = slices.DeleteFunc(effectiveRoles, func(role *entity.SysRole) bool {
|
||||
return role.RoleId == consts.SuperAdminRoleId
|
||||
})
|
||||
}
|
||||
for _, role := range effectiveRoles {
|
||||
roleIds = append(roleIds, role.RoleId)
|
||||
}
|
||||
isPlatformSuperAdmin := contexts.GetTenantId(ctx) == consts.DefaultSystemTenantCode && slices.Contains(roleIds, consts.SuperAdminRoleId)
|
||||
managed := false
|
||||
if !isPlatformSuperAdmin {
|
||||
template, templateErr := rolepolicy.Template(ctx)
|
||||
if templateErr != nil {
|
||||
return nil, nil, templateErr
|
||||
}
|
||||
managed = template != nil && template.TenantId == contexts.GetTenantId(ctx) && template.DeptId != contexts.GetDeptId(ctx)
|
||||
}
|
||||
|
||||
for _, role := range effectiveRoles {
|
||||
accessCodeList = append(accessCodeList, consts.SysCheckPermissionRolePrefix+role.RoleKey)
|
||||
@@ -391,7 +400,7 @@ func (s *sSysAuth) GetUserAccessCodeList(ctx context.Context, userId int64) (acc
|
||||
for _, menu := range rmList {
|
||||
menuIds = append(menuIds, menu.MenuId)
|
||||
}
|
||||
if !contexts.IsSuperAdmin(ctx) {
|
||||
if !isPlatformSuperAdmin {
|
||||
menuIds, err = rolepolicy.RestrictMenus(ctx, contexts.GetTenantId(ctx), contexts.GetDeptId(ctx), menuIds)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
Reference in New Issue
Block a user