WireMock.Net: Unauthorized (401) error when calling the admin API with version 2 Azure AAD tokens.

Describe the bug

The issuwer from https://login.microsoftonline.com/{tennantID}/.well-known/openid-configuration is given as https://sts.windows.net/{tennantID}/ but when you decode a v2 AAD token using jwt.ms, the issuer is set as https://login.microsoftonline.com/{tennantID}/v2.0 And the recommendation is that instead of comparing the entire string, you should only compare that the tennants match. The identity model even has a helper method for validating the issuwer https://github.com/AzureAD/microsoft-identity-web/blob/36fb5f555638787823a89e89c67f17d6a10006ed/tools/CrossPlatformValidator/CrossPlatformValidation/CrossPlatformValidation/RequestValidator.cs#L42

Expected behavior:

I can make wiremock admin API requests with with AAD version 2 tokens

Test to reproduce

  1. Configure Wiremock server with AAD
  2. Generate an AAD token with version 2 https://learn.microsoft.com/en-us/entra/identity-platform/msal-acquire-cache-tokens
  3. Send a request to the server for the wiremock admin requests e.g /__admin/requests and you’ll get 401 instead of 200

Other related info

Provide additional information if any.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17

Most upvoted comments

@StefH I downloaded the nupkg from here https://dev.azure.com/stef/WireMock.Net/_build/results?buildId=9960&view=artifacts&pathAsName=false&type=publishedArtifacts and ran the specific version.

I can confirm that the bug is now fixed I’m authenticating with 200

Image

Hello @StefH

Thanks for the fast response, I’ll be able to test it out on Monday next week.