Library version used
1.23.1
Java version
Java 25
Scenario
ManagedIdentityClient - managed identity
Is this a new or an existing app?
None
Issue description and reproduction steps
When setting the environment variable AZURE_POD_IDENTITY_AUTHORITY_HOST to a custom url, e.g. http://127.0.0.1:80 the full imds endpoint is not built correctly.
The bug is in the constructor of class com.microsoft.aad.msal4j.IMDSManagedIdentitySource. The class contains a variable IMDS_TOKEN_PATH that is set to /metadata/identity/oauth2/token. When AZURE_POD_IDENTITY_AUTHORITY_HOST is set, the endpoint is built with the following code:
StringBuilder builder = new StringBuilder(environmentVariables.getEnvironmentVariable(Constants.AZURE_POD_IDENTITY_AUTHORITY_HOST));
builder.append("/" + IMDS_TOKEN_PATH);
This causes the imdsEndpoint to contain an extra /, thus the endpoint becomes http://127.0.0.1:80//metadata/identity/oauth2/token which causes a resource not found exception from Azure.
Relevant code snippets
Expected behavior
For the imds endpoint to be built correctly without a double /
Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
Regression
No response
Solution and workarounds
The fix is to remove the extra /.
Library version used
1.23.1
Java version
Java 25
Scenario
ManagedIdentityClient - managed identity
Is this a new or an existing app?
None
Issue description and reproduction steps
When setting the environment variable
AZURE_POD_IDENTITY_AUTHORITY_HOSTto a custom url, e.g.http://127.0.0.1:80the full imds endpoint is not built correctly.The bug is in the constructor of class
com.microsoft.aad.msal4j.IMDSManagedIdentitySource. The class contains a variableIMDS_TOKEN_PATHthat is set to/metadata/identity/oauth2/token. WhenAZURE_POD_IDENTITY_AUTHORITY_HOSTis set, the endpoint is built with the following code:This causes the imdsEndpoint to contain an extra
/, thus the endpoint becomeshttp://127.0.0.1:80//metadata/identity/oauth2/tokenwhich causes a resource not found exception from Azure.Relevant code snippets
Expected behavior
For the imds endpoint to be built correctly without a double /
Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
Regression
No response
Solution and workarounds
The fix is to remove the extra
/.