-
Notifications
You must be signed in to change notification settings - Fork 361
MSAL.NET uses web browser
There is one important thing that beginners with authentication libraries and Azure AD don't immediately understand: this is the fact that when getting token interactively, the content of the dialog box is not provided by the library, but really by the STS: the authentication endpoint sends some HTML and JavaScript which control the interaction. Delegating this dialog (this dance) to the STS has many advantages:
- enabling redirections to other identity providers (for instance login-in with a work school account or a personal account with MSAL, or with a social account with B2C)
- letting the STS control conditional access, for instance by having the user do multiple factor authentication during this authentication phase (entering a windows hello pin, or being called on his phone, or on an authentication app on his phone). In cases where multi factor authentication is required and the user has not set it up yet, s/he can even set it up just in time in the same dialog, entering his mobile phone number, and being guided to install an authentication application and scan a QR tag to add his account. This is an amazing experience!
- Letting the user change his password in this same dialog when the password has expired (providing additional fields for the old password and the new password)
- Enabling branding of the tenant, or the application (images) controlled by the Azure AD tenant admin / application owner.
- Enabling the user to consent to let the application access resources / scopes in his name just after the authentication.
- Last but not least, the password (if one was typed) is never stored by the application, nor the library.
To host this interaction with the STS, ADAL.NET uses an embedded web browser. For all the platforms that provide UI (read not .NET Core), a dialog is provided by the library embedding a Web browser control. MSAL.NET also uses an embedded web view for the .NET Desktop, and WAB for the UWP platforms and windows phone 8.1 applications, but leverages the system web browser for Xamarin iOS and Xamarin Android applications. Using the system web view has the big advantage of sharing the SSO state with other applications and with web applications without needing a browser. This was done in the Xamarin iOS and Xamarin Android platforms because on those, the system web browser occupies the whole screen, and the user experience is good. The system web view is not distinguishable from a dialog. For desktop applications, however, launching a System web view leads to a very weird user experience, as the user sees the browser, where he might already have other tabs opened, and there he gets a page asking him/her to close this window. If he does not pay attention, s/he can close the whole browser (including other tabs which are unrelated to the authentication). This would also require opening local ports and listening on them, which might require advanced permissions for the application. Note, finally, that for .NET Core, acquisition of tokens interactively is not available. Indeed, .NET Core does not provide UI yet.
- Home
- Why use MSAL.NET
- Is MSAL.NET right for me
- Scenarios
- Register your app with AAD
- Client applications
- Acquiring tokens
- MSAL samples
- Known Issues
- AcquireTokenInteractive
- WAM - the Windows broker
- .NET Core
- Maui Docs
- Custom Browser
- Applying an AAD B2C policy
- Integrated Windows Authentication for domain or AAD joined machines
- Username / Password
- Device Code Flow for devices without a Web browser
- ADFS support
- Acquiring a token for the app
- Acquiring a token on behalf of a user in Web APIs
- Acquiring a token by authorization code in Web Apps
- High Availability
- Token cache serialization
- Logging
- Exceptions in MSAL
- Provide your own Httpclient and proxy
- Extensibility Points
- Clearing the cache
- Client Credentials Multi-Tenant guidance
- Performance perspectives
- Differences between ADAL.NET and MSAL.NET Apps
- PowerShell support
- Testing apps that use MSAL
- Experimental Features
- Proof of Possession (PoP) tokens
- Using in Azure functions
- Extract info from WWW-Authenticate headers
- SPA Authorization Code