Skip to content

[Bug] Interactivity switch incorrect for Linux #5246

Open
@abbottdev

Description

@abbottdev

Library version used

MSAL 4.64.0

.NET version

.NET 9.0

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, I haven't upgraded MSAL, but started seeing this issue

Issue description and reproduction steps

I'm trying to use the Microsoft Artifact credential provider for nuget here: https://github.com/microsoft/artifacts-credprovider

The credential provider invokes MSAL under the hood. For vscode remote SSH sessions - vscode exposes the $BROWSER env var which is an .sh script which invokes the default browser on the default host.

If xdg-open is also installed, then the interactivity (open-able) browser state is true. Currently the check in MSAL for linux checks whether $DISPLAY is defined - which it is not for vscode SSH sessions, but $BROWSER is.

I believe the code lines here:

        private static bool IsInteractiveSessionLinux()
        {
            return !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("DISPLAY"));
        }

https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/c892032762192dcbd23f14936f7852ff6da26b21/src/client/Microsoft.Identity.Client/PlatformsCommon/Shared/DesktopOsHelper.cs#L201C13-L201C94

Should be changed to check whether $BROWSER is defined OR $DISPLAY is defined IMO.

I have validated this works by setting $DISPLAY to false and vscode's remote SSH session launches an interactive browser session on my host PC. This would be a really nice feature to get worked into both the vscode repo and the azure artifacts flow.

Relevant code snippets

https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/c892032762192dcbd23f14936f7852ff6da26b21/src/client/Microsoft.Identity.Client/PlatformsCommon/Shared/DesktopOsHelper.cs#L201C13-L201C94

Expected behavior

Opens a browser natively on the user's machine when the Remote-SSH vscode host has $BROWSER is defined.

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

As above, set $DISPLAY to a non nullish value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions