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

[Feature Request] Include a win-arm runtime library in the Microsoft.Identity.Client.NativeInterop NuGet package #4901

Open
austinbhale opened this issue Aug 22, 2024 · 4 comments

Comments

@austinbhale
Copy link

MSAL client type

Public, Managed identity

Problem statement

Which version of MSAL.NET are you using?

  • Microsoft.Identity.Client, Version="4.63.0"
  • Microsoft.Identity.Client.Broker, Version="4.63.0"
  • Microsoft.Identity.Client.NativeInterop, Version="0.16.1"

Scenario: Silently acquiring a token via AcquireTokenSilent in a HoloLens 2 application that targets ARM, not ARM64. Microsoft.Identity.Client.NativeInterop includes runtimes for win-arm64, win-x64, and win-x86. My request is to include the win-arm binary as well.

You cannot rename msalruntime_arm64.dll to msalruntime_arm.dll, as that'd be a bad image format, and I don't believe you can tell the API to look for the arm64 dependency as well. So, I think the ARM32 build would be required here.

Exception Message: System.DllNotFoundException: 'Unable to load DLL 'msalruntime_arm' or one of its dependencies: The specified module could not be found.

Example Code

IPublicClientApplication app;
IAccount account;
BrokerOptions options = new(BrokerOptions.OperatingSystems.Windows)
{
#if WINDOWS_UWP || WINDOWS
    ListOperatingSystemAccounts = true,
#endif
    Title = "Azure Sample"
};

try
{
    // Authority URL is a defined start with addition of the tenant which can be 'common', 'organizations' or a tenant Id.
    string authority = string.Format(CultureInfo.InvariantCulture, AuthorityTemplate, tenantId);

    // Create the auth client using the broker of the OS to get the current user.
    app = PublicClientApplicationBuilder
        .Create(clientId)
        .WithAuthority(authority)
        .WithBroker(options)
        .Build();
}
catch (MsalClientException ex)
{
    Log.Err($"Unable to build the public client application! {ex.Message}");
    return null;
}

try
{
    // Get the logged in user account from the OS.
    account = PublicClientApplication.OperatingSystemAccount;
    string[] scopesList = scopes.Split(' ');

    // Acquire the access token silently.
    AuthenticationResult result =
        await app.AcquireTokenSilent(scopesList, account)
                  .ExecuteAsync(cancellationToken)
                  .ConfigureAwait(false);
    return result;
}
catch (Exception ex)
{
    Log.Err($"AuthenticateSilentAsync: {ex.Message}");
    return null;
}

Proposed solution

I'd be happy to build the native source code, but it seems the project is missing at https://github.com/AzureAD/microsoft-authentication-library-for-cpp. If the native code is proprietary, then including the ARM runtime in the next release would be perfect. Thanks for your time!

Alternatives

No response

@austinbhale austinbhale added needs attention Delete label after triage untriaged Do not delete. Needed for Automation labels Aug 22, 2024
@austinbhale austinbhale changed the title [Feature Request] [Feature Request] Include a win-arm runtime library in the Microsoft.Identity.Client.NativeInterop NuGet package Aug 22, 2024
@austinbhale
Copy link
Author

austinbhale commented Aug 22, 2024

The latest non-vulnerable implementation of the silent token acquisition on UWP is version 4.47.2, before the new brokers were introduced. It seems UWP has lost support via #4427 (comment). When reverting the package version, this issue was resolved.

For anyone else facing this issue, I hope this code can help out: https://github.com/Nakamir-Code/SKAzureCloud/blob/master/Nakamir.Azure.Security/AuthenticationHelper.cs#L140-L189

@bgavrilMS bgavrilMS added bug P2 WAM public-client and removed untriaged Do not delete. Needed for Automation needs attention Delete label after triage public-client labels Aug 22, 2024
@bgavrilMS
Copy link
Member

bgavrilMS commented Aug 22, 2024

I'm going to mark this as a bug, as Windows on ARM is becoming more popular now and the SDKs should not block on CPU arch

@bgavrilMS bgavrilMS reopened this Aug 22, 2024
@bgavrilMS bgavrilMS removed the P2 label Aug 22, 2024
@bgavrilMS
Copy link
Member

Note that arm64 is supported. I think this is a request for arm32. Removing the priority.

@austinbhale
Copy link
Author

Seems Arm32 support is deprecated org-wide, so definitely no big deal on my end. Glad I can use the older package version! As I wait for a non-UWP mixed reality headset 😄

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

3 participants