Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: reload iam cache (#15923)

boojackfd24eba7128c
diff --git a/backend/api/directory-sync/webhook.go b/backend/api/directory-sync/webhook.go
index 9aa283cfa4..c42dd1b4a8 100644
--- a/backend/api/directory-sync/webhook.go
+++ b/backend/api/directory-sync/webhook.go
@@ -548,6 +548,10 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
if err != nil {
return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to update group, error %v", err))
}
+ // Reload IAM cache to make sure the group members are updated.
+ if err := s.iamManager.ReloadCache(ctx); err != nil {
+ return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to reload iam cache, error %v", err))
+ }
return c.JSON(http.StatusOK, convertToAADGroup(updatedGroup))
})
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.go
index 6d555d9d5a..90cbaf8e8f 100644
--- a/backend/api/v1/auth_service.go
+++ b/backend/api/v1/auth_service.go
@@ -489,6 +489,7 @@ func (s *AuthService) syncUserGroups(ctx context.Context, user *store.UserMessag
return status.Errorf(codes.Internal, "failed to list groups: %v", err)
}
+ groupChanged := false
for _, bbGroup := range bbGroups {
var isMember bool
for _, group := range groups {
@@ -522,6 +523,14 @@ func (s *AuthService) syncUserGroups(ctx context.Context, user *store.UserMessag
}); err != nil {
return status.Errorf(codes.Internal, "failed to update group %q: %v", bbGroup.Email, err)
}
+ groupChanged = true
+ }
+ }
+
+ // Reload IAM cache if group membership changed.
+ if groupChanged {
+ if err := s.iamManager.ReloadCache(ctx); err != nil {
+ return status.Errorf(codes.Internal, "failed to reload IAM cache: %v", err)
}
}