# Disabling a connection in an Application doesn't stop a user logging in

**URL:** <https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [September 30, 2025, 9:25am UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572 "2025-09-30T09:25:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris.butler](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.butler/32/70985_2.png) [@chris.butler](https://community.auth0.com/u/chris.butler)\
**Post date:** [September 30, 2025, 9:25am UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572/1 "2025-09-30T09:25:35Z")

</div>

We have multiple SAML enterprise connections (Conn\_1, Conn\_2, Conn\_3, etc) with Home Realm Discovery enabled.  
We have multiple applications (App\_1, App\_2, etc).

We have one application (App\_1) with an enabled connection to one of the SAML enterprise connections (Conn\_1) but none of the others (Conn\_2 etc).

When we try to log into that application (App\_1) with an email address that is referenced by Home Realm Discovery to another connection (Conn\_2), we are finding that it redirects us to that connections Identity Provider for login.

I expected that as the connection was disabled, Home Realm Discovery would not be triggered for the connection.

Any ideas what we could be doing wrong?

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [September 30, 2025, 1:44pm UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572/3 "2025-09-30T13:44:00Z")

</div>

Hi @chris.butler,

Welcome to the Auth0 Community!

The behavior you’re observing is expected because **Home Realm Discovery (HRD) operates at the tenant level, not the application level**. It identifies the user’s enterprise connection based on their email domain _before_ checking if that connection is enabled for the specific application they are trying to access.

The most direct and modern way to solve this is to create a custom **Action** that runs after HRD but before the final login is complete. This Action will verify that the connection selected by HRD is actually enabled for the application in question.

Here’s how you can set it up:

1. In your Auth0 Dashboard, navigate to **Actions \> Library**.

2. Click **Build Custom** and create a new Action with the following settings:

- **Name** : `Enforce Application Connections`
- **Trigger** : **Login / Post Login**
- **Runtime** : **Node 18** (or your preferred runtime)

1. In the code editor, paste the following script. This script checks if the connection the user is logging in with is included in the list of connections enabled for the current application.

```javascript
/**
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login transaction.
*/
exports.onExecutePostLogin = async (event, api) => {
  // Find the connection the user is authenticating with.
  // In federated logins, the strategy is the connection name (e.g., "samlp").
  // The `event.connection.name` holds the unique name of the connection.
  const connectionUsed = event.connection.name;

  // Get the list of connections that are explicitly enabled for the current application.
  // This is an array of connection names.
  const enabledConnections = event.client.enabled_connections || [];

  // Check if the connection being used is in the application's list of enabled connections.
  if (!enabledConnections.includes(connectionUsed)) {
    // If not, deny access and provide a clear error message.
    api.access.deny(
      'access_denied',
      `The '${connectionUsed}' connection is not enabled for this application.`
    );
  }
};

```

1. Click **Deploy**.

2. Finally, add this Action to the Login flow. Go to **Actions \> Flows \> Login**.

3. Drag your new **Enforce Application Connections** Action from the right-hand panel and drop it into the flow.

Now, when a user tries to log in, this Action will run and prevent them from using a connection that isn’t explicitly enabled for the application they are accessing, stopping the process before a session is created.

If you have any further questions, please don’t hesitate to reach out.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![chris.butler](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.butler/32/70985_2.png) [@chris.butler](https://community.auth0.com/u/chris.butler)\
**Post date:** [September 30, 2025, 1:53pm UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572/4 "2025-09-30T13:53:36Z")

</div>

Hi @vlad.murarasu,

Thanks for the response. Its great to have clarify on what is expected.

It makes me question the value of enabling and disabling connections under and application? What is the purpose of this if HRD is going to be triggered regardless?

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [September 30, 2025, 2:10pm UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572/5 "2025-09-30T14:10:32Z")

</div>

Hi @chris.butler,

The primary purpose of the **Enabled Connections** setting on an application is to **control the UI of the Universal Login page** by determining which login buttons are displayed to the user. HRD operates at an earlier stage of the login flow, which is why its behavior can seem counterintuitive.

Its primary role is to configure the UI for users who aren’t automatically routed by HRD. The Action I’ve suggested simply enforces that same logic earlier in the process for a more robust and intuitive flow.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![chris.butler](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.butler/32/70985_2.png) [@chris.butler](https://community.auth0.com/u/chris.butler)\
**Post date:** [September 30, 2025, 2:53pm UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572/6 "2025-09-30T14:53:34Z")

</div>

Thanks for the reply and understanding. Its massively appreciated.

Is it possible to make a suggestion/feature request that HRD becomes an application level concern instead of the tenant level concern? It feels like it could be a good opportunity to the use of connections within applications for federated connections

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [September 30, 2025, 3:40pm UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572/7 "2025-09-30T15:40:03Z")

</div>

Yes, you can submit a Product Feedback topic and request that this feature be implemented.

> **[Product Feedback](https://community.auth0.com/c/feedback/95)**
>
> Submit and vote on Auth0 product features

Everyone else who thinks they can leverage this feature can vote on your Product Feedback.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![chris.butler](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.butler/32/70985_2.png) [@chris.butler](https://community.auth0.com/u/chris.butler)\
**Post date:** [October 1, 2025, 12:37pm UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572/8 "2025-10-01T12:37:41Z")

</div>

> [@vlad.murarasu](#):
>
> ```auto
> const enabledConnections = event.client.enabled_connections || [];
> 
> ```

Hi,

Thanks for the link.

I’ve just begun coding this and can’t see enabled\_connections being available in the client object within the docs? Is this an unsupported property?

I’ve navigated to: /docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger/post-login-event-object

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [October 1, 2025, 12:56pm UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572/9 "2025-10-01T12:56:35Z")

</div>

Hi @chris.butler,

Apologies for my mistake. The enabled connections are not available inside the `event.client` object but need to be accessed using the Management API.

Here is the documentation for the `Get enabled connections for a client` endpoint:

> **[Auth0 Management API v2](https://auth0.com/docs/api/management/v2/clients/get-client-connections)**

You can leverage the `ManagementClient` for use within the Action:

> **[Clients | Auth0 Node.js SDK - v5.0.0](https://auth0.github.io/node-auth0/classes/management.SDK.Clients.html#connections)**
>
> Documentation for Auth0 Node.js SDK

If you have any further questions, please don’t hesitate to reach out.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 15, 2025, 12:56pm UTC](https://community.auth0.com/t/disabling-a-connection-in-an-application-doesnt-stop-a-user-logging-in/192572/10 "2025-10-15T12:56:49Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
