1
0
forked from baron/baron-sso

feat: remove automatic default group creation during tenant registration

This commit is contained in:
2026-03-04 15:26:58 +09:00
parent 4392810ec7
commit d3b4e3ef5e

View File

@@ -112,51 +112,6 @@ func (s *tenantService) RegisterTenant(ctx context.Context, name, slug, tenantTy
return nil, err
}
// [New] Create Default User Groups
if s.userGroupRepo != nil {
groups := []struct {
Name string
Slug string
}{
{Name: "임직원", Slug: "members"},
{Name: "관리자", Slug: "admins"},
}
for _, g := range groups {
newGroup := &domain.UserGroup{
TenantID: tenant.ID,
Name: g.Name,
Slug: g.Slug,
Description: tenant.Name + " " + g.Name + " 그룹",
}
if err := s.userGroupRepo.Create(ctx, newGroup); err == nil {
// Sync group to Keto via Outbox
if s.outboxRepo != nil {
_ = s.outboxRepo.Create(ctx, &domain.KetoOutbox{
Namespace: "Tenant",
Object: newGroup.ID,
Relation: "parents",
Subject: "Tenant:" + tenant.ID,
Action: domain.KetoOutboxActionCreate,
})
// If this is the 'admins' group and we have a creatorID, add creator to this group
if g.Slug == "admins" && creatorID != "" {
_ = s.outboxRepo.Create(ctx, &domain.KetoOutbox{
Namespace: "Tenant",
Object: newGroup.ID,
Relation: "owners",
Subject: "User:" + creatorID,
Action: domain.KetoOutboxActionCreate,
})
}
}
} else {
slog.Error("Failed to create default group", "group", g.Slug, "tenant", tenant.ID, "error", err)
}
}
}
// [Keto] Sync hierarchy and ownership via Outbox
if s.outboxRepo != nil {
// Sync hierarchy
@@ -256,37 +211,6 @@ func (s *tenantService) ApproveTenant(ctx context.Context, id string) error {
return err
}
// [New] Create Default User Groups upon approval
if s.userGroupRepo != nil {
groups := []struct {
Name string
Slug string
}{
{Name: "임직원", Slug: "members"},
{Name: "관리자", Slug: "admins"},
}
for _, g := range groups {
newGroup := &domain.UserGroup{
TenantID: tenant.ID,
Name: g.Name,
Slug: g.Slug,
Description: tenant.Name + " " + g.Name + " 그룹",
}
if err := s.userGroupRepo.Create(ctx, newGroup); err == nil {
if s.outboxRepo != nil {
_ = s.outboxRepo.Create(ctx, &domain.KetoOutbox{
Namespace: "Tenant",
Object: newGroup.ID,
Relation: "parents",
Subject: "Tenant:" + tenant.ID,
Action: domain.KetoOutboxActionCreate,
})
}
}
}
}
// [Keto] Sync relation via Outbox
if s.outboxRepo != nil {
if adminEmail, ok := tenant.Config["adminEmail"].(string); ok && adminEmail != "" {