# Define which organizations can access app

**URL:** <https://community.auth0.com/t/define-which-organizations-can-access-app/80702>\
**Category:** Get Help\
**Tags:** organizations\
**Created:** [March 29, 2022, 1:01pm UTC](https://community.auth0.com/t/define-which-organizations-can-access-app/80702 "2022-03-29T13:01:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric.krief](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/eric.krief/32/30834_2.png) [@eric.krief](https://community.auth0.com/u/eric.krief)\
**Post date:** [March 29, 2022, 1:01pm UTC](https://community.auth0.com/t/define-which-organizations-can-access-app/80702/1 "2022-03-29T13:01:55Z")

</div>

I have multiple organizations and multiple applications all within one tenant.  
I am trying to only allow certain organization to access certain apps.  
I can’t find a way to do so, is it possible?

---

<div class="post-metadata">

**Author:** ![adam.housman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adam.housman/32/19907_2.png) [@adam.housman](https://community.auth0.com/u/adam.housman)\
**Post date:** [March 29, 2022, 1:23pm UTC](https://community.auth0.com/t/define-which-organizations-can-access-app/80702/2 "2022-03-29T13:23:33Z")

</div>

Hi @eric.krief, application entitlement can be achieved using a Post-Login [Action](https://auth0.com/docs/customize/actions/actions-overview).

You can see the organization parameters that are exposed in the event object when an end-user is logging in with an Organization here: [Actions Triggers: post-login - Event Object](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow/event-object).

You could use a list of Organization IDs to gate access, or use organization metadata for a more maintainable approach… I added an example starting point below.

```auto
/**
 * @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.
 */
exports.onExecutePostLogin = async (event, api) => {
  if (event.client.name === "Protected App") {
    if !(event.organization && event.organization.metadata && event.organization.metadata["subscription"] === "paid")
      api.access.deny("Access to this application requires a paid subscription.");
    }
  }
};

```

---

<div class="post-metadata">

**Author:** ![eric.krief](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/eric.krief/32/30834_2.png) [@eric.krief](https://community.auth0.com/u/eric.krief)\
**Post date:** [March 29, 2022, 3:38pm UTC](https://community.auth0.com/t/define-which-organizations-can-access-app/80702/3 "2022-03-29T15:38:29Z")

</div>

Hi Adam, thanks for the quick reply!  
Would you consider this approach secure?

---

<div class="post-metadata">

**Author:** ![adam.housman](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/adam.housman/32/19907_2.png) [@adam.housman](https://community.auth0.com/u/adam.housman)\
**Post date:** [March 29, 2022, 3:53pm UTC](https://community.auth0.com/t/define-which-organizations-can-access-app/80702/4 "2022-03-29T15:53:48Z")

</div>

Hi @eric.krief,

I can tell you that (at the time of writing this) the only time the `organization` object will be present on the event is when:

1. An end-user has successfully authenticated with a connection that is enabled for the provided organization and
2. The end-user is either a member of the organization or the `enabled_connection` has auto-membership defined.

“Secure” depends on a lot of factors so I recommend taking a holistic approach to defining what is and isn’t acceptable for your use-case, and also taking a look at our docs: [Secure](https://auth0.com/docs/secure).

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 29, 2022, 4:10pm UTC](https://community.auth0.com/t/define-which-organizations-can-access-app/80702/5 "2022-03-29T16:10:35Z")

</div>

Thank you Adam for helping us on this front!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 28, 2022, 10:23am UTC](https://community.auth0.com/t/define-which-organizations-can-access-app/80702/6 "2022-04-28T10:23:53Z")

</div>


