Since B2C on behalf of is not supported, what are the options of passing in a secure way using the azure infrastructure the identity of a user downstream?
After Web app --> Web Api 1, B2C cannot generate (to my knowledge) token with user claim to be used in Web Api 2
Also, when it reach that point, no interaction with the client is possible so token should be acquired silently or used as-is, if the token was expired, proper error handling should be triggered and the user would have to retry with a new token
I can think of a few way;
Generating all token in the client and passing them down;
- not a good idea since the client should not be aware of what is going on downstream
Passing the refresh token downstream so API can generate tokens;
- the refresh token is very sensitive so should be handled with extreme care
Stopping using azure b2c past the Web Api 1;
- handling everything outside of B2C, not ideal since from that point on it fall into "custom code"
at the end of the day goal is to transfers claims downstream to have the identity of the user and making sure it was not tampered with
I tried to reproduce the same in my environment and got the results like below:
I created two Web APIs and granted API permissions in Client Application like below:
Now, I generated authorization code by using below endpoint:
I generated access token using authorization code flow:
By using the above access token, I generated access token using On-Behalf-Of Flow by using scope of web api2:
When I decoded the token, it has
api2scopelike below:When I tried to use Azure AD B2C User Flows, I got the error like below: