FrankieA
FrankieA

Reputation: 278

How to manage multiple Tenants, ClientIDs and Endpoints with ADAL js frontend?

Background:

Problem:

As per the ADAL js wiki found here: https://github.com/AzureAD/azure-activedirectory-library-for-js/wiki/Config-authentication-context, our frontend application must specify the ClientID and backend API Endpoints when initializing ADAL.

Since each of our tenants has their own ClientID, we ended up adding all the possible ClientIDs and Endpoints into our code, and figuring out the values at runtime based on the current URL. This obviously doesn't scale very well as it requires a code change for each new tenant. We are thinking moving this work to the the CI/CD process, but are trying to understand if there is a better solution.

Is there a better way to manage multiple, single-tenant apps with ADAL js?

Upvotes: 2

Views: 499

Answers (1)

Martin Brandl
Martin Brandl

Reputation: 58921

Since each instance of your application is registered separately (thus has its own ClientId), ADAL.js doesn't provide you a better solution.

You can either work with Angular Environments e. g.

environment.tenant1.ts
enviornment.tenant2.ts

And create a build artifact for each tenant using ng build --prod ---configuration=tenant1. I don't like this solution since you have multiple build artifacts.

Or you expose a middleware / REST API that returns the configuration for a specific client by its URL. This will be the only endpoint your client needs to know. However, you have to ensure the middleware is always up (single point of failure).

Upvotes: 0

Related Questions