Although this feature is not available today in Azure AD, you can implement this scenario if you add Auth0 to the mix. Auth0 supports multi-tasking Azure AD applications as a connection for your applications and using the rules mechanism , you can write rules to restrict access to a specific application based on the Azure AD tenant.
Here is an example of how such a rule (which runs in the Auth0 authentication pipeline, after authenticating the user in Azure AD and before the user can access your application):
function (user, context, callback) { if(context.clientName !== 'NameOfTheAppWithWhiteList'){ var whitelist = [ 'tenantId1', 'tenantId2' ]; //authorized Azure AD tenants. var userHasAccess = whitelist.some( function (tenantId) { return tenantId === user.tenantid; }); if (!userHasAccess) { return callback(new UnauthorizedError('Access denied.')); } } callback(null, user, context); }
Disclaimer I work for Auth0.
source share