forked from baron/baron-sso
fix: align UserGroup ReBAC syncing with Tenant namespace design
This commit is contained in:
@@ -130,9 +130,9 @@ func (s *orgChartService) ImportCSV(ctx context.Context, tenantID string, r io.R
|
|||||||
|
|
||||||
// 3. Sync Membership to Keto via Outbox
|
// 3. Sync Membership to Keto via Outbox
|
||||||
if s.ketoOutboxRepo != nil {
|
if s.ketoOutboxRepo != nil {
|
||||||
// Add as member of UserGroup
|
// Add as member of UserGroup (which is a Tenant namespace object)
|
||||||
_ = s.ketoOutboxRepo.Create(ctx, &domain.KetoOutbox{
|
_ = s.ketoOutboxRepo.Create(ctx, &domain.KetoOutbox{
|
||||||
Namespace: "UserGroup",
|
Namespace: "Tenant",
|
||||||
Object: leafID,
|
Object: leafID,
|
||||||
Relation: "members",
|
Relation: "members",
|
||||||
Subject: "User:" + kratosID,
|
Subject: "User:" + kratosID,
|
||||||
@@ -142,7 +142,7 @@ func (s *orgChartService) ImportCSV(ctx context.Context, tenantID string, r io.R
|
|||||||
// Add as owner if applicable
|
// Add as owner if applicable
|
||||||
if isOwner {
|
if isOwner {
|
||||||
_ = s.ketoOutboxRepo.Create(ctx, &domain.KetoOutbox{
|
_ = s.ketoOutboxRepo.Create(ctx, &domain.KetoOutbox{
|
||||||
Namespace: "UserGroup",
|
Namespace: "Tenant",
|
||||||
Object: leafID,
|
Object: leafID,
|
||||||
Relation: "owners",
|
Relation: "owners",
|
||||||
Subject: "User:" + kratosID,
|
Subject: "User:" + kratosID,
|
||||||
|
|||||||
@@ -133,9 +133,9 @@ func (s *tenantService) RegisterTenant(ctx context.Context, name, slug, tenantTy
|
|||||||
// Sync group to Keto via Outbox
|
// Sync group to Keto via Outbox
|
||||||
if s.outboxRepo != nil {
|
if s.outboxRepo != nil {
|
||||||
_ = s.outboxRepo.Create(ctx, &domain.KetoOutbox{
|
_ = s.outboxRepo.Create(ctx, &domain.KetoOutbox{
|
||||||
Namespace: "UserGroup",
|
Namespace: "Tenant",
|
||||||
Object: newGroup.ID,
|
Object: newGroup.ID,
|
||||||
Relation: "tenants",
|
Relation: "parents",
|
||||||
Subject: "Tenant:" + tenant.ID,
|
Subject: "Tenant:" + tenant.ID,
|
||||||
Action: domain.KetoOutboxActionCreate,
|
Action: domain.KetoOutboxActionCreate,
|
||||||
})
|
})
|
||||||
@@ -143,9 +143,9 @@ func (s *tenantService) RegisterTenant(ctx context.Context, name, slug, tenantTy
|
|||||||
// If this is the 'admins' group and we have a creatorID, add creator to this group
|
// If this is the 'admins' group and we have a creatorID, add creator to this group
|
||||||
if g.Slug == "admins" && creatorID != "" {
|
if g.Slug == "admins" && creatorID != "" {
|
||||||
_ = s.outboxRepo.Create(ctx, &domain.KetoOutbox{
|
_ = s.outboxRepo.Create(ctx, &domain.KetoOutbox{
|
||||||
Namespace: "UserGroup",
|
Namespace: "Tenant",
|
||||||
Object: newGroup.ID,
|
Object: newGroup.ID,
|
||||||
Relation: "members",
|
Relation: "owners",
|
||||||
Subject: "User:" + creatorID,
|
Subject: "User:" + creatorID,
|
||||||
Action: domain.KetoOutboxActionCreate,
|
Action: domain.KetoOutboxActionCreate,
|
||||||
})
|
})
|
||||||
@@ -276,9 +276,9 @@ func (s *tenantService) ApproveTenant(ctx context.Context, id string) error {
|
|||||||
if err := s.userGroupRepo.Create(ctx, newGroup); err == nil {
|
if err := s.userGroupRepo.Create(ctx, newGroup); err == nil {
|
||||||
if s.outboxRepo != nil {
|
if s.outboxRepo != nil {
|
||||||
_ = s.outboxRepo.Create(ctx, &domain.KetoOutbox{
|
_ = s.outboxRepo.Create(ctx, &domain.KetoOutbox{
|
||||||
Namespace: "UserGroup",
|
Namespace: "Tenant",
|
||||||
Object: newGroup.ID,
|
Object: newGroup.ID,
|
||||||
Relation: "tenants",
|
Relation: "parents",
|
||||||
Subject: "Tenant:" + tenant.ID,
|
Subject: "Tenant:" + tenant.ID,
|
||||||
Action: domain.KetoOutboxActionCreate,
|
Action: domain.KetoOutboxActionCreate,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user