Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call user_info endpoint for AAD guest scenarios #18

Closed
jennyf19 opened this issue Feb 18, 2020 · 2 comments
Closed

Call user_info endpoint for AAD guest scenarios #18

jennyf19 opened this issue Feb 18, 2020 · 2 comments

Comments

@jennyf19
Copy link
Collaborator

jennyf19 commented Feb 18, 2020

Why?

TokenAcquistion.cs has hacks to try to guess guest scenarios. In the case of guest scenarios the home tenant ID, home object id is different from the tenantID, object ID which are provided in the IDToken. But we don't have today the home tid/oid information, and therefore we don't know that this is a guest user.
MSAL.NET uses the home tenant information, and therefore in the guest scenarios we don't find find the tokens in the cache today (I believe UniqueObjectIdentifier)

// Special case for guest users as the Guest oid / tenant id are not surfaced.
// B2C should not follow this logic since loginHint is not present
if (!_microsoftIdentityOptions.IsB2C && account == null)
{
if (loginHint == null)
throw new ArgumentNullException(nameof(loginHint));
var accounts = await application.GetAccountsAsync().ConfigureAwait(false);
account = accounts.FirstOrDefault(a => a.Username == loginHint);
}

and

// Workaround for the guest account
if (account == null)
{
var accounts = await app.GetAccountsAsync().ConfigureAwait(false);
account = accounts.FirstOrDefault(a => a.Username == user.GetLoginHint());
}
if (account != null)
{
await app.RemoveAsync(account).ConfigureAwait(false);
_tokenCacheProvider?.ClearAsync().ConfigureAwait(false);
}

The hypothesis is that we'd want to call the User info endpoint not only for B2C, but also AAD, and get the home tenant ID, home iod, instead of the hack.

What ?

  • Like we do w/B2C, call the user_info endpoint for AAD guest scenarios. Today we test for B2C. We probably want to do the same or similar for AAD.

    if (microsoftIdentityOptions.IsB2C)
    {
    context.ProtocolMessage.SetParameter("client_info", "1");
    // When a new Challenge is returned using any B2C user flow different than susi, we must change
    // the ProtocolMessage.IssuerAddress to the desired user flow otherwise the redirect would use the susi user flow
    await b2cOidcHandlers.OnRedirectToIdentityProvider(context).ConfigureAwait(false);
    }

  • probably (to be checked) change the GetMsalId method to use the home tenant information?

public static string GetMsalAccountId(this ClaimsPrincipal claimsPrincipal)

  • if this is successful, remove the hacks?

How to test?

Otherwise we could add an hotmail account in a test tenant. Alternatively the identity lab will have guest accounts.

@jennyf19 jennyf19 self-assigned this Feb 18, 2020
@jmprieur
Copy link
Collaborator

@jennyf19 this would be a good one to take if other issues are not fully spec-ed

@jennyf19
Copy link
Collaborator Author

jennyf19 commented Jun 1, 2020

In 0.1.4-preview release

@jennyf19 jennyf19 closed this as completed Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants