forked from baron/baron-sso
4단계 역할 정규화 및 dev 권한 스코프 검증 강화
This commit is contained in:
@@ -34,15 +34,16 @@ func SyncKetoRelations(db *gorm.DB, keto service.KetoService) error {
|
||||
}
|
||||
slog.Info("Syncing users to Keto", "count", len(users))
|
||||
for _, u := range users {
|
||||
role := domain.NormalizeRole(u.Role)
|
||||
// Membership
|
||||
if u.TenantID != nil {
|
||||
_ = keto.CreateRelation(ctx, "Tenant", *u.TenantID, "members", "User:"+u.ID)
|
||||
}
|
||||
|
||||
// Roles
|
||||
if u.Role == domain.RoleSuperAdmin {
|
||||
if role == domain.RoleSuperAdmin {
|
||||
_ = keto.CreateRelation(ctx, "System", "global", "super_admins", "User:"+u.ID)
|
||||
} else if u.Role == domain.RoleTenantAdmin && u.TenantID != nil {
|
||||
} else if role == domain.RoleTenantAdmin && u.TenantID != nil {
|
||||
_ = keto.CreateRelation(ctx, "Tenant", *u.TenantID, "admins", "User:"+u.ID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user