Skip to content

Commit 98e2530

Browse files
committed
feat: performance improvement
1 parent 225b61e commit 98e2530

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

internal/scim/scim.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ func (s *Provider) GetGroupsMembersBruteForce(ctx context.Context, gr *model.Gro
523523
// brute force implemented here thanks to the fxxckin' aws sso scim api
524524
// iterate over each group and user and check if the user is a member of the group
525525
for _, group := range gr.Resources {
526-
// initialize the members slice for the group
527-
membersByGroup[group.SCIMID] = make([]*model.Member, 0)
526+
// initialize the members slice for the group. Optimistic approach
527+
membersByGroup[group.SCIMID] = make([]*model.Member, 0, 10)
528528

529529
for _, user := range ur.Resources {
530530

@@ -545,7 +545,7 @@ func (s *Provider) GetGroupsMembersBruteForce(ctx context.Context, gr *model.Gro
545545
return fmt.Errorf("scim: error listing groups: %w", err)
546546
}
547547

548-
slog.Debug("checking group membership", "group_name", group.Name, "user_email", user.Emails[0].Value, "results", lgr.TotalResults)
548+
// slog.Debug("checking group membership", "group_name", group.Name, "user_email", user.Emails[0].Value, "results", lgr.TotalResults)
549549

550550
// AWS SSO SCIM API, it doesn't return the member into the Resources array
551551
if lgr.TotalResults > 0 {
@@ -555,9 +555,11 @@ func (s *Provider) GetGroupsMembersBruteForce(ctx context.Context, gr *model.Gro
555555
WithSCIMID(user.SCIMID).
556556
WithEmail(user.Emails[0].Value).
557557
Build()
558+
558559
if user.Active {
559560
m.Status = "ACTIVE"
560561
}
562+
561563
mu.Lock()
562564
membersByGroup[group.SCIMID] = append(membersByGroup[group.SCIMID], m)
563565
mu.Unlock()

pkg/aws/scim.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,6 @@ func (s *SCIMService) CreateUser(ctx context.Context, cur *CreateUserRequest) (*
229229
return nil, fmt.Errorf("aws CreateUser: user: %s, error decoding response body: %w", cur.UserName, err)
230230
}
231231

232-
slog.Debug("aws CreateUser()", "response", response)
233-
234232
return &response, nil
235233
}
236234

0 commit comments

Comments
 (0)