diff --git a/pkg/services/authn/authnimpl/sync/org_sync.go b/pkg/services/authn/authnimpl/sync/org_sync.go index fcc5526463971..0b9ce6f7e80a4 100644 --- a/pkg/services/authn/authnimpl/sync/org_sync.go +++ b/pkg/services/authn/authnimpl/sync/org_sync.go @@ -33,31 +33,31 @@ func (s *OrgSync) SyncOrgRolesHook(ctx context.Context, id *authn.Identity, _ *a return nil } - ctxLogger := s.log.FromContext(ctx) + ctxLogger := s.log.FromContext(ctx).New("id", id.ID, "login", id.Login) namespace, identifier := id.GetNamespacedID() if namespace != authn.NamespaceUser { - ctxLogger.Warn("Failed to sync org role, invalid namespace for identity", "id", id.ID, "namespace", namespace) + ctxLogger.Warn("Failed to sync org role, invalid namespace for identity", "namespace", namespace) return nil } userID, err := identity.IntIdentifier(namespace, identifier) if err != nil { - ctxLogger.Warn("Failed to sync org role, invalid ID for identity", "id", id.ID, "namespace", namespace, "err", err) + ctxLogger.Warn("Failed to sync org role, invalid ID for identity", "namespace", namespace, "err", err) return nil } - ctxLogger.Debug("Syncing organization roles", "id", id.ID, "extOrgRoles", id.OrgRoles) + ctxLogger.Debug("Syncing organization roles", "extOrgRoles", id.OrgRoles) // don't sync org roles if none is specified if len(id.OrgRoles) == 0 { - ctxLogger.Debug("Not syncing organization roles since external user doesn't have any", "id", id.ID) + ctxLogger.Debug("Not syncing organization roles since external user doesn't have any") return nil } orgsQuery := &org.GetUserOrgListQuery{UserID: userID} result, err := s.orgService.GetUserOrgList(ctx, orgsQuery) if err != nil { - ctxLogger.Error("Failed to get user's organizations", "id", id.ID, "error", err) + ctxLogger.Error("Failed to get user's organizations", "error", err) return nil } @@ -75,7 +75,7 @@ func (s *OrgSync) SyncOrgRolesHook(ctx context.Context, id *authn.Identity, _ *a // update role cmd := &org.UpdateOrgUserCommand{OrgID: orga.OrgID, UserID: userID, Role: extRole} if err := s.orgService.UpdateOrgUser(ctx, cmd); err != nil { - ctxLogger.Error("Failed to update active org user", "id", id.ID, "error", err) + ctxLogger.Error("Failed to update active org user", "error", err) return err } } @@ -93,17 +93,17 @@ func (s *OrgSync) SyncOrgRolesHook(ctx context.Context, id *authn.Identity, _ *a cmd := &org.AddOrgUserCommand{UserID: userID, Role: orgRole, OrgID: orgId} err := s.orgService.AddOrgUser(ctx, cmd) if err != nil && !errors.Is(err, org.ErrOrgNotFound) { - ctxLogger.Error("Failed to update active org for user", "id", id.ID, "error", err) + ctxLogger.Error("Failed to update active org for user", "error", err) return err } } // delete any removed org roles for _, orgID := range deleteOrgIds { - ctxLogger.Debug("Removing user's organization membership as part of syncing with OAuth login", "id", id.ID, "orgId", orgID) + ctxLogger.Debug("Removing user's organization membership as part of syncing with OAuth login", "orgId", orgID) cmd := &org.RemoveOrgUserCommand{OrgID: orgID, UserID: userID} if err := s.orgService.RemoveOrgUser(ctx, cmd); err != nil { - ctxLogger.Error("Failed to remove user from org", "id", id.ID, "orgId", orgID, "error", err) + ctxLogger.Error("Failed to remove user from org", "orgId", orgID, "error", err) if errors.Is(err, org.ErrLastOrgAdmin) { continue } @@ -112,7 +112,7 @@ func (s *OrgSync) SyncOrgRolesHook(ctx context.Context, id *authn.Identity, _ *a } if err := s.accessControl.DeleteUserPermissions(ctx, orgID, cmd.UserID); err != nil { - ctxLogger.Error("Failed to delete permissions for user", "id", id.ID, "orgId", orgID, "error", err) + ctxLogger.Error("Failed to delete permissions for user", "orgId", orgID, "error", err) } }