[management] Push network maps when background validation changes (#8299)

An integrated validator can approve or revoke peers outside a login or
sync, for example during a periodic EDR sync. Only revocations of SSO
peers reached anyone; a newly approved peer kept its empty map, and its
peers did not see it, until an unrelated update or a reconnect.

Add SetPeerValidationChangeListener to the IntegratedValidator interface.
The account manager registers a handler that resolves the affected peers
and calls OnPeersUpdated, the same path a login-time approval takes. The
OSS validator and the mock implement it as a no-op.
This commit is contained in:
Maycon Santos
2026-10-22 22:57:47 +02:00
committed by GitHub
parent f548a74c7c
commit 8397bed4af
6 changed files with 100 additions and 0 deletions
+19
View File
@@ -298,6 +298,9 @@ func BuildManager(
am.integratedPeerValidator.SetPeerInvalidationListener(func(accountID string, peerIDs []string) {
am.onPeersInvalidated(ctx, accountID, peerIDs)
})
am.integratedPeerValidator.SetPeerValidationChangeListener(func(accountID string, peerIDs []string) {
am.onPeerValidationChanged(ctx, accountID, peerIDs)
})
// Started last: a manager that fails to build is never returned, so nothing would
// stop its refresher.
@@ -2102,6 +2105,22 @@ func (am *DefaultAccountManager) onPeersInvalidated(ctx context.Context, account
log.WithContext(ctx).Debugf("invalidated peers have been expired for account %s", accountID)
}
// onPeerValidationChanged pushes fresh network maps to peers whose validation state
// changed in the background, and to the peers that can reach them.
func (am *DefaultAccountManager) onPeerValidationChanged(ctx context.Context, accountID string, peerIDs []string) {
if len(peerIDs) == 0 {
return
}
affected := am.resolveAffectedPeersForPeerChanges(ctx, am.Store, accountID, peerIDs)
if len(affected) == 0 {
// Resolution failed or found nothing; the changed peers' own maps still differ.
affected = peerIDs
}
if err := am.networkMapController.OnPeersUpdated(ctx, accountID, peerIDs, affected); err != nil {
log.WithContext(ctx).Errorf("failed to update peers after validation change for account %s: %v", accountID, err)
}
}
func (am *DefaultAccountManager) FindExistingPostureCheck(accountID string, checks *posture.ChecksDefinition) (*posture.Checks, error) {
return am.Store.GetPostureCheckByChecksDefinition(accountID, checks)
}