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

[Bug] Token acquisition from different tenant not working #344

Closed
1 task done
zvrba opened this issue Jul 21, 2020 · 6 comments
Closed
1 task done

[Bug] Token acquisition from different tenant not working #344

zvrba opened this issue Jul 21, 2020 · 6 comments
Assignees
Labels
bug Something isn't working fixed P1
Milestone

Comments

@zvrba
Copy link

zvrba commented Jul 21, 2020

Which version of Microsoft Identity Web are you using?
Commit ID 8a043b7 , but the same problem experienced also with -master dated 2020-07-21.

Where is the issue?

  • Web API
    • Protected web APIs call downstream web APIs

Is this a new or an existing app?
The app is in production and I have upgraded to a new version of Microsoft Identity Web.

Repro

            var tokenAcquisition = httpContext.RequestServices.GetRequiredService<Microsoft.Identity.Web.ITokenAcquisition>();
            var tid = httpContext.User.FindFirst("tid").Value;
            return tokenAcquisition.GetAccessTokenForUserAsync(new string[] { scope }, tid);

Expected behavior
Token issued by tenant B.

Actual behavior
When user in tenant A is a guest user in tenant B (identified by "tid"), this call returns a token issued by tenant A instead of token issued by tenant B ("tid").

Possible solution
Please see the attached patch. This is the same bug I previously reported for an older version.

TokenAcquisition.cs.txt

@zvrba zvrba changed the title [Bug] [Bug] Token acquisition from different tenant not working Jul 21, 2020
@jmprieur jmprieur added bug Something isn't working P1 labels Jul 22, 2020
@jmprieur jmprieur added this to the [3] Fundamentals milestone Jul 24, 2020
@jennyf19
Copy link
Collaborator

@zvrba I'm not able to repro this at the moment. Could you verify if the tenant admin has disabled user consent?

@jennyf19 jennyf19 self-assigned this Jul 27, 2020
@zvrba
Copy link
Author

zvrba commented Jul 28, 2020

The application has a tenant-wide admin consent. I'm not sure which setting you're asking about, so I'm attaching a screenshot below.

Further details:

  • The admin of tenant B has granted a tenant-wide consent for the application
  • The user authenticates to the /common endpoint end receives a Graph token from its home tenant (tenant A)
  • Then my web api uses the above snippet with "tid" set to tenant B (where the user is a guest) to request another Graph token.
  • Using the token to query for a specific object in the directory fails with "Not found" because the token's issuer is A instead of B.

Debugging showed me a bunch of MSAL exceptions ("login hint not provided") which i traced back to the == vs != fix in the provided patch. Adding the authority to application builder may or may not have had an effect.

image

@jennyf19
Copy link
Collaborator

@zvrba thanks for the additional info. I didn't see the patch in the original post, will take a look. thx.

@jennyf19
Copy link
Collaborator

This issue is fixed in microsoft identity web, but there is an additional fix needed in msal .net, so moving this to blocked for now. That work will be in progress soon.

@jennyf19
Copy link
Collaborator

jennyf19 commented Aug 4, 2020

moving this to done for us, as MSAL .NET has a fix that will go out in their next release.

@jennyf19 jennyf19 added fixed and removed blocked labels Aug 4, 2020
@jennyf19
Copy link
Collaborator

jennyf19 commented Aug 7, 2020

Included in 0.2.2-preview release

@jennyf19 jennyf19 closed this as completed Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed P1
Projects
None yet
Development

No branches or pull requests

3 participants