Skip to content

Commit 895c116

Browse files
committed
updating linux docs for .net
1 parent 0395468 commit 895c116

4 files changed

Lines changed: 428 additions & 189 deletions

File tree

msal-dotnet-articles/TOC.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
- name: Acquiring tokens interactively
3030
href: acquiring-tokens/desktop-mobile/acquiring-tokens-interactively.md
3131
- name: Using MSAL.NET with Web Account Manager (WAM)
32-
href: acquiring-tokens/desktop-mobile/wam.md
32+
href: acquiring-tokens/desktop-mobile/wam.
33+
- name: using MSAL.Net with broker on Linux distributions
34+
href: acquiring-tokens/desktop-mobile/linux-dotnet-sdk.md
35+
- name: using MSAL.Net with WSL
36+
href: acquiring-tokens/desktop-mobile/linux-dotnet-sdk-wsl.md
3337
- name: Xamarin
3438
href: acquiring-tokens/desktop-mobile/mobile-applications.md
3539
- name: Sign-in users with social identities

msal-dotnet-articles/acquiring-tokens/desktop-mobile/linux-broker-net.md

Lines changed: 0 additions & 188 deletions
This file was deleted.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
title: Enable SSO in WSL apps using MSAL.NET and WAM
3+
description: Learn how to integrate Microsoft Entra ID authentication in WSL apps using MSAL.NET and the Microsoft Single Sign-on for Linux broker.
4+
author: ploegert
5+
ms.author: jploegert
6+
ms.service: msal
7+
ms.topic: how-to
8+
ms.date: 05/08/2025
9+
---
10+
11+
# Enable SSO in WSL (Windows Subsystem for Linux) apps using MSAL.NET and WAM
12+
13+
MSAL is able to call the Microsoft Single Sign-on to Linux, a Linux component that is shipped independent of the Linux Distribution, however it gets installed using a package manager using `sudo apt install microsoft-identity-broker` or `sudo dnf install microsoft-identity-broker`.
14+
15+
This component acts as an authentication broker allowing the users of your app to benefit from integration with accounts known to Linux, such as the account you signed into your Linux sessions for apps that consume from the broker. It's also bundled as a dependency of applications developed by Microsoft, such as [Company Portal](/mem/intune-service/user-help/enroll-device-linux). These applications are 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).
16+
17+
> [!NOTE]
18+
> Microsoft single sign-on (SSO) for Linux authentication broker support is introduced with `Microsoft.Identity.Client` version v4.69.1.
19+
20+
Using an authentication broker on Linux enables you to simplify how your users authenticate with Microsoft Entra ID from your application, and take advantage of future functionality that protects Microsoft Entra ID refresh tokens from exfiltration and misuse.
21+
22+
To enable SSO in your WSL app using MSAL.NET, you must ensure the keychain is set up and unlocked, as MSAL uses `libsecret` to communicate with the keyring daemon.
23+
24+
## Update to the latest version of WSL
25+
26+
Ensure you have updated to the latest WSL release. The WAM Account Control dialog is supported in WSL versions 2.4.13 and above.
27+
28+
```powershell
29+
# To check what distros are available:
30+
wsl.exe --list --online
31+
32+
wsl.exe --install Ubuntu-22.04
33+
34+
# To check the WSL version:
35+
wsl --version
36+
37+
# To update WSL:
38+
wsl --update
39+
```
40+
41+
## Prerequisites
42+
43+
### .NET Installation
44+
Identity integration dependent on having dotnet 8 installed on the Linux distribution, and recommend installing via the [installation script](https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install).
45+
46+
```bash
47+
# Download the install script
48+
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
49+
chmod +x ./dotnet-install.sh
50+
./dotnet-install.sh --version latest
51+
52+
# To update the path if using bash (remember to reset your connection afterword):
53+
vi .bashrc
54+
export DOTNET_ROOT=~/.dotnet
55+
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools
56+
```
57+
58+
### Set up Keyring in WSL
59+
60+
MSAL uses `libsecret` on Linux. It's required to communicate with the `keyring` daemon. Users can use [Seahorse](https://wiki.gnome.org/Apps/Seahorse/) (a GNOME application for managing encryption keys and passwords) to manage the `keyring` contents through a Graphical User Interface (GUI).
61+
62+
On Debian-based distributions, you can install the package by running `sudo apt install seahorse` and then following these instructions:
63+
64+
1. Run `seahorse` in the terminal.
65+
66+
![WSL1](../../media/wam/wsl1.png)
67+
68+
2. In the top left corner, select **+** and create **Password** keyring.
69+
70+
![WSL2](../../media/wam/wsl2.png)
71+
72+
3. Create a keyring named 'login'
73+
74+
![WSL3](../../media/wam/wsl3.png)
75+
76+
4. Set the password on the next dialog.
77+
![WSL4](../../media/wam/wsl4.png)
78+
79+
5. Run `wsl.exe --shutdown` from your Windows Terminal.
80+
81+
6. Start a new WSL session and run the sample. You should be asked for the keyring password.
82+
83+
### Package Dependencies
84+
85+
Install the following dependencies on your Linux platform:
86+
87+
- `libsecret-tools` is required to interface with the Linux keychain
88+
- `libx11-dev` package, where the `libx11` library is used to get the console window handle on Linux.
89+
90+
### [Ubuntu](#tab/ubuntudep)
91+
92+
To install on debian/Ubuntu based Linux distribution:
93+
94+
```bash
95+
sudo apt install libx11-dev libc++-dev libc++abi-dev libsecret-tools libwebkit2gtk-4.0 -y
96+
```
97+
98+
### [Red Hat Enterprise Linux](#tab/rheldep)
99+
100+
To install on Red Hat/Fedora based Linux distribution:
101+
102+
```bash
103+
sudo dnf install libx11-dev libc++-dev libc++abi-dev libsecret-tools libwebkit2gtk-4.0 -y
104+
```
105+
106+
---
107+
108+
## Run a Sample App
109+
110+
To use a broker on the Linux platform, make sure you set the `BrokerOptions` to `OperatingSystems.Linux` as shown in the below code snippet:
111+
112+
Reference the [Enable SSO in native Linux apps using MSAL.NET](./linux-dotnet-sdk.md) for information of how to configure the project.
113+
114+
To set up a test app, you use the sample app provided in [microsoft-authentication-library-for-dotnet](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) under the path [/tests/devapps/WAM/NetWSLWam/Class1.cs](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/main/tests/devapps/WAM/NetWSLWam/Class1.cs)
115+
116+
117+
To run the sample app:
118+
119+
```bash
120+
# Run From the root folder of microsoft-authentication-library-dotnet directory
121+
dotnet run --project tests/devapps/WAM/NetWSLWam/test.csproj
122+
```

0 commit comments

Comments
 (0)