I need assistance to understand the how Azure B2C can work in case if multiple APIs are required.
We have in this sample: https://api01.azurefunction.com/ https://api02.azurefunction.com/
B2C Instance samples.onmicrosoft.com
API01 exposes scope: https://samples.onmicrosoft.com/api01/read
API02 expose scope: https://samples.onmicrosoft.com/api02/write
WebApp uses MSAL.NET (Microsoft.Identity.Client 4.9.0) and can request scopes ONLY for one API. Any attempts to request scopes for two different resources will fail, it's limitation in AD/B2C in case if used ConfidentialClientApplicationBuilder.
My attempts initiate multiple round trips to STS by requesting scopes were failed. Even if it would work, it cannot be considered for production use due to possibility of showing consent screen.
In that point I need advice how to work in current case.
I have multiple options:
Implement facade for these API and provide single point to request data. But this has drawbacks at least of consuming resources. Other significant limitation it's On-Behalf-Of not supported in B2C. Therefore I need to invent how to call underling Azure Functions with incoming security context.
Use API Management instance with AD integration but price so big for our project (~2K/month)
Use a "hack" to define "Allowed Token audiences" for AD protected Azure Function to allow accept tokens acquired for one resource but sent to another. This work but I will be limited in scopes because list of scopes will be defined by the resource to which token was acquired. As a variation I can register "fake" application and always acquire tokens to that application.
Implement custom AccessToken binders in Azure Function and completely invent a wheel :(
Option #3 looks good. Has some limitations but I hope I can deal with that.
But in final, in case if I will need communicate with Azure APIs such as AD Graph API how to get a token? Use RBAC?
Please assist with this.