# Azure AD multitenant - what goes in allowed\_domains?

**URL:** <https://discuss.pomerium.com/t/azure-ad-multitenant-what-goes-in-allowed-domains/128>\
**Category:** Support\
**Created:** [June 1, 2022, 8:01pm UTC](https://discuss.pomerium.com/t/azure-ad-multitenant-what-goes-in-allowed-domains/128 "2022-06-01T20:01:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick132135](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@patrick132135](https://discuss.pomerium.com/u/patrick132135)\
**Post date:** [June 1, 2022, 8:01pm UTC](https://discuss.pomerium.com/t/azure-ad-multitenant-what-goes-in-allowed-domains/128/1 "2022-06-01T20:01:53Z")

</div>

## What happened?

I’m using Azure AD as my identity provider. I followed [Microsoft Entra ID (formerly Azure Active Directory) | Pomerium](https://www.pomerium.com/docs/identity-providers/azure) and am able to login and view [authenticate.example.com/.pomerium](http://authenticate.example.com/.pomerium). However, when I configure a route with `allowed_domains`, I get 403 Forbidden (the Pomerium page, not my app’s) when accessing that route (after successfully logging in).

I would like to support logins from multiple Azure AD, so enabled multitenant on my registered application. I’ve configured my route with `allowed_domains` containing the email domain of my Azure user, my Azure AD tenant ID, and an alternate domain ([xxx.onmicrosoft.com](http://xxx.onmicrosoft.com)). All of these are met with 403 Forbidden as above.

A route configured with `allow_any_authenticated_user: true` works OK.

## What did you expect to happen?

Access to be allowed.

## What’s your environment like?

- Pomerium version 0.17.3
- Linux, kubernetes, helm chart 31.1.7

## What’s your config.yaml?

```auto
idp_provider: azure
# other idp config provided via env vars
routes:
- from: https://app.example.com
  prefix: /debug/httpbin
  prefix_rewrite: /
  to: http://httpbin.httpbin
  allow_any_authenticated_user: true
  pass_identity_headers: true
- from: https://app.example.com
  to: http://app
  allowed_domains: ["example.com", "< Azure AD tenant UUID >", "xxx.onmicrosoft.com"]
  pass_identity_headers: true
- from: https://authenticate.example.com
  to: https://pomerium-authenticate.default.svc.cluster.local
  allow_public_unauthenticated_access: true

```

## What did you see in the logs?

The logs from pomerium-authorize contain:

```logs
"allow":false,"allow-why-false":["domain-unauthorized","non-pomerium-route"],"deny":false,"deny-why-false":["valid-client-certificate-or-none-required"]

```

## Additional context

Summary: everything works when I configure `allow_any_authenticated_user: true`. But I’m not sure what to put in `allowed_domains` to restrict to certain Azure AD domains (tenants?). I turned on debug-level logging, but I don’t see anything that suggests what the current domain of my logged-in user actually is.

---

<div class="post-metadata">

**Author:** ![patrick132135](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@patrick132135](https://discuss.pomerium.com/u/patrick132135)\
**Post date:** [June 2, 2022, 3:54pm UTC](https://discuss.pomerium.com/t/azure-ad-multitenant-what-goes-in-allowed-domains/128/2 "2022-06-02T15:54:17Z")

</div>

Skimming through Pomerium code, it looks like “domain” is parsed out of a user’s email address (see [domain.go](https://github.com/pomerium/pomerium/blob/0b0fba06b3374557ed7427d165190570ce4997f1/pkg/policy/criteria/domain.go#L10-L20)).

And from the Troubleshooting section of the [Azure AD docs](https://www.pomerium.com/docs/identity-providers/azure#troubleshooting):

> In our testing, we found that users could be created in an Active Directory without an email address as part of their user claim. Pomerium user identity depends largely on the associated email address.

Which now makes perfect sense, since with no email, there is no domain that could be matched in `allowed_domains`.

Inside Azure AD, it seemed insufficient to edit the user to add “Contact info / Email”; I also had to set “Contact info / Altername email” to the same value (or perhaps I simply had not waited long enough for the change to propagate).

At any rate, the [https://authenticate.example.com/.pomerium](https://authenticate.example.com/.pomerium) user info page previously had no `Email` field, and now it does. And now `allowed_domains` appears to work as expected.

---

<div class="post-metadata">

**Author:** ![alex](https://yyz1.discourse-cdn.com/flex031/user_avatar/discuss.pomerium.com/alex/32/9_2.png) [@alex](https://discuss.pomerium.com/u/alex)\
**Post date:** [June 22, 2022, 9:45pm UTC](https://discuss.pomerium.com/t/azure-ad-multitenant-what-goes-in-allowed-domains/128/3 "2022-06-22T21:45:46Z")

</div>

Hi @patrick132135. Sorry I didn’t respond to this post earlier, but I’m glad you got the issue resolved.

As our technical writer, I’d be happy to get any feedback on that doc; if there’s anything else we can say (or say it differently) to make this quirk of Azure more apparent.
