-
Notifications
You must be signed in to change notification settings - Fork 40
Add doc about linux broker on dotnet scenario #646
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
Closed
xinyuxu1026
wants to merge
39
commits into
MicrosoftDocs:main
from
xinyuxu1026:linux-dotnet-with-broker
Closed
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
c631925
add doc about linux broker on dotnet scenario
xinyuxu1026 ffa809e
add more info
xinyuxu1026 83ccb15
update author
xinyuxu1026 2be64ed
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 3c184e4
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden e30b448
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 182fe07
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden e425098
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden d0b2baf
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 2099411
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 2fca0c8
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 17e2eb3
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden ae7f038
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 269356c
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 82e796f
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 5907d42
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 2e29b6e
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden c973e74
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 871cfdd
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden 82d1694
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
localden b65ae78
Address comments
xinyuxu1026 528ab4a
Update linux-broker-net.md
localden 1cd63df
add sample code
xinyuxu1026 e07e91f
Merge branch 'linux-dotnet-with-broker' of https://github.com/xinyuxu…
xinyuxu1026 d83a3a4
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 384f135
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 837040d
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 4a28d7e
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 fe81a0e
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 bac9b31
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 d1bee1e
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 904d17c
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 ee47017
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 23e7903
address comments
xinyuxu1026 934edbc
add screenshot and .net install
xinyuxu1026 ddffeae
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 749cb8d
Update msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-bro…
xinyuxu1026 65ce187
add more screenshot
xinyuxu1026 b5c37a3
more update
xinyuxu1026 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
add doc about linux broker on dotnet scenario
- Loading branch information
commit c631925747abb478ecd6b18d4186681ddf31b224
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-broker-net.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
# Required metadata | ||
# For more information, see https://review.learn.microsoft.com/en-us/help/platform/learn-editor-add-metadata?branch=main | ||
# For valid values of ms.service, ms.prod, and ms.topic, see https://review.learn.microsoft.com/en-us/help/platform/metadata-taxonomies?branch=main | ||
|
||
title: # Add a title for the browser tab | ||
description: # Add a meaningful description for search results | ||
author: ploegert, xinyuxu1026 # GitHub alias | ||
ms.author: jploegert, xinyuxu # Microsoft alias | ||
ms.service: # Add the ms.service or ms.prod value | ||
# ms.prod: # To use ms.prod, uncomment it and delete ms.service | ||
ms.topic: # Add the ms.topic value | ||
ms.date: 05/05/2025 | ||
--- | ||
|
||
# Using MSAL .NET with an Authentication Broker on Linux | ||
|
||
|
||
> [!NOTE] | ||
> Microsoft Single Sign-on for Linux authentication broker support is introduced with `MSAL.NET` version v4.69.1. | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Using an authentication broker on Linux enables you to simplify how your users authenticate with Microsoft Entra ID from your application, as well as take advantage of future functionality that protects Microsoft Entra ID refresh tokens from exfiltration and misuse. | ||
xinyuxu1026 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Authentication brokers are **not** pre-installed on Linux but is bundled as a dependency of applications developed by Microsoft, such as [Company Portal](/mem/intune-service/user-help/enroll-device-linux). These applications are usually installed when a Linux computer is enrolled in a company's device fleet via an endpoint management solution like [Microsoft Intune](/mem/intune/fundamentals/what-is-intune). To learn more about Linux device set up with the Microsoft Identity Platform, refer to [Microsoft Enterprise SSO plug-in for Apple devices](/entra/identity-platform/apple-sso-plugin). | ||
xinyuxu1026 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Dependency | ||
xinyuxu1026 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To use the broker, you will need to install a list of dependencies on Linux platform | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also include a step that explains how to install msalruntime nuget package for linux as it is a necessary step for broker support
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```bash | ||
xinyuxu1026 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
libc++-dev | ||
libc++abi-dev | ||
libsecret-tools | ||
libwebkit2gtk-4.0 | ||
``` | ||
|
||
## Create a console app on Linux platform | ||
xinyuxu1026 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
To use broker on Linux platform, you need to specify the `BrokerOptions` to `OperationsSystems.Linux`. Notice that we use the same option for both Windows Subsystem for Linux (WSL) and standalone Linux. | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```dotnet | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from msal import PublicClientApplication | ||
|
||
class Program | ||
{ | ||
xinyuxu1026 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public static string ClientID = "your client id"; //msidentity-samples-testing tenant | ||
public static string[] Scopes = { "User.Read" }; | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Hello World!"); | ||
|
||
var pcaBuilder = PublicClientApplicationBuilder.Create(ClientID) | ||
.WithAuthority("https://login.microsoftonline.com/common") | ||
.WithDefaultRedirectUri() | ||
.WithBroker(new BrokerOptions(BrokerOptions.OperatingSystems.Linux){ | ||
ListOperatingSystemAccounts = true, | ||
MsaPassthrough = true, | ||
Title = "MSAL WSL Test App" | ||
}) | ||
.Build(); | ||
|
||
AcquireTokenInteractiveParameterBuilder atparamBuilder = pcaBuilder.AcquireTokenInteractive(Scopes); | ||
|
||
AuthenticationResult authenticationResult = atparamBuilder.ExecuteAsync().GetAwaiter().GetResult(); | ||
System.Console.WriteLine(authenticationResult.AccessToken); | ||
} | ||
} | ||
``` | ||
|
||
xinyuxu1026 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Sample App | ||
There is a sample app in MSAL.NET repo, it's under ./tests/devapps/WAM/NetWSLWam path. The sample app has a dependenc of `libx11-dev` package. Please run `apt install libx11-dev` to install the package. To run the sample app, just run the command below. | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dotnet run --project tests\devapps\WAM\NetWSLWam\test.csproj | ||
``` | ||
|
||
## WSL Scenario | ||
|
||
### Update to the latest version of WSL | ||
Please make sure you have updated to the most recent version of WSL. Account control page is supported from WSL version 2.4.13. Otherwise, the broker scenario won't work. Here is the command to update WSL. | ||
``` | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
wsl.exe --update | ||
xinyuxu1026 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
### Set up Keyring in WSL | ||
We use libsecret on Linux and it needs to communicate with keyring daemon. Users can use `seahorse`(gnome GUI) package to manage the keyring with a user interface. You need to first install the package by `apt install seahorse` and then follow the instructions below. | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
1. Run seahorse command | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
2. On the top left corner, click "+" and create Password keyring | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. Create a keyring with name 'login', and set the password | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
4. Run wsl.exe --shutdown | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
5. Start a new wsl window and run the test, it should ask you for the keyring password | ||
localden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.