Skip to content

Commit fb42059

Browse files
committed
fix: update AUTH0 connection handling to respect include list
- Adjusted logic to ensure 'enterprise-saml' is not marked for deletion when not in the include list. - Modified tests to reflect that 'google-oauth2' should not be deleted if it's not in the include list. - Updated behavior to only delete managed connections when assets are empty, preserving unmanaged ones. - Ensured that unmanaged connections are ignored during updates, preventing unintended deletions.
1 parent 4013d75 commit fb42059

6 files changed

Lines changed: 9046 additions & 19168 deletions

src/tools/auth0/handlers/connections.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,6 @@ export default class ConnectionsHandler extends DefaultAPIHandler {
603603
};
604604

605605
const includedConnections = (assets.include && assets.include.connections) || [];
606-
const filteredConnections =
607-
includedConnections.length > 0
608-
? connections.filter((conn) => includedConnections.includes(conn.name))
609-
: connections;
610606

611607
// Convert enabled_clients by name to the id
612608
const clients = await paginate<Client>(this.client.clients.list, {
@@ -619,6 +615,11 @@ export default class ConnectionsHandler extends DefaultAPIHandler {
619615
include_totals: true,
620616
});
621617

618+
const filteredConnections =
619+
includedConnections.length > 0
620+
? connections.filter((conn) => includedConnections.includes(conn.name))
621+
: connections;
622+
622623
// Prepare an id map. We'll use this map later to get the `strategy` and SCIM enable status of the connections.
623624
await this.scimHandler.createIdMap(existingConnections);
624625

@@ -627,8 +628,18 @@ export default class ConnectionsHandler extends DefaultAPIHandler {
627628
...this.getFormattedOptions(connection, clients),
628629
enabled_clients: getEnabledClients(assets, connection, existingConnections, clients),
629630
}));
631+
630632
const proposedChanges = await super.calcChanges({ ...assets, connections: formatted });
631633

634+
if (includedConnections.length > 0) {
635+
proposedChanges.del = proposedChanges.del.filter((connection) =>
636+
includedConnections.includes(connection.name)
637+
);
638+
proposedChanges.update = proposedChanges.update.filter((connection) =>
639+
includedConnections.includes(connection.name)
640+
);
641+
}
642+
632643
const proposedChangesWithExcludedProperties = addExcludedConnectionPropertiesToChanges({
633644
proposedChanges,
634645
existingConnections,

0 commit comments

Comments
 (0)