microsoft-authentication-library-for-java icon indicating copy to clipboard operation
microsoft-authentication-library-for-java copied to clipboard

Add file based Azure Arc detection

Open Avery-Dunn opened this issue 6 months ago • 2 comments

Fixes the issue described in https://github.com/AzureAD/microsoft-authentication-library-for-java/issues/846, and is similar to the fix in MSAL .NET: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/pull/4856

This PR adds file-based detection of Azure Arc, in addition to the current detection based on environment variables. If the files are found but the identity endpoint variable is not set, we default to a known endpoint.

Avery-Dunn avatar May 14 '25 21:05 Avery-Dunn

Needs at least a test for whatever OS the CI is using.

@bgavrilMS : I originally didn't add tests because it is very difficult to modify static/final variables in a test and our mocking framework doesn't allow mocks of low-level Java features like file manipulation, and the PR over in .NET didn't have them so I figured y'all ran into similar issues too.

However, in the latest commit I removed the 'final' modifier from the final paths and added some package-private setters, allowing the tests to create temp directories to test the new behavior. We have some similar used-for-tests-only setters for a few other fields that otherwise could be private, and this is basically the only way to have meaningful tests for this file detection.

Avery-Dunn avatar May 21 '25 17:05 Avery-Dunn

You might find msal-node's implementation of this feature interesting. It can be found in this file.

Robbie-Microsoft avatar May 28 '25 14:05 Robbie-Microsoft