Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal class RuntimeBroker : IBroker
}
catch (MsalRuntimeException ex) when (ex.Status == ResponseStatus.ApiContractViolation)
{
// failed to initialize msal runtime - can happen on older versions of Windows. Means broker is not available.
// failed to initialize MSAL runtime - can happen on older versions of Windows. Means broker is not available.
// We will never get here with our current OS version check. Instead in this scenario we will fallback to the browser
// but MSALRuntime does it's internal check for OS compatibility and throws an ApiContractViolation MsalRuntimeException.
// For any reason, if our OS check fails then this will catch the MsalRuntimeException and
Expand All @@ -67,7 +67,7 @@ internal class RuntimeBroker : IBroker
}
catch (Exception ex)
{
// When MSAL Runtime dlls fails to load then we catch the exception and throw with a meaningful
// When MSAL Runtime DLL fails to load then we catch the exception and throw with a meaningful
// message with information on how to troubleshoot
throw new MsalClientException(
"wam_runtime_init_failed", ex.Message + " See https://aka.ms/msal-net-wam#troubleshooting", ex);
Expand Down Expand Up @@ -127,7 +127,7 @@ public async Task<MsalTokenResponse> AcquireTokenInteractiveAsync(
AcquireTokenInteractiveParameters acquireTokenInteractiveParameters)
{
using LogEventWrapper logEventWrapper = new LogEventWrapper(this);
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if msal runtime init failed");
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if MSAL runtime init failed");
MsalTokenResponse msalTokenResponse = null;

//need to provide a handle
Expand Down Expand Up @@ -169,7 +169,7 @@ public async Task<MsalTokenResponse> AcquireTokenInteractiveAsync(
readAccountResult.Account,
cancellationToken).ConfigureAwait(false))
{
var errorMessage = "Could not login interactively.";
var errorMessage = "Could not acquire token interactively.";
msalTokenResponse = WamAdapters.HandleResponse(result, authenticationRequestParameters, _logger, errorMessage);
}
}
Expand All @@ -179,9 +179,6 @@ public async Task<MsalTokenResponse> AcquireTokenInteractiveAsync(
$"[RuntimeBroker] Could not find a WAM account for the selected user {authenticationRequestParameters.Account.Username}, error: {readAccountResult.Error}",
$"[RuntimeBroker] Could not find a WAM account for the selected user. Error: {readAccountResult.Error}");

_logger?.Info(
$"[RuntimeBroker] Calling SignInInteractivelyAsync this will show the account picker.");

msalTokenResponse = await SignInInteractivelyAsync(
authenticationRequestParameters, acquireTokenInteractiveParameters)
.ConfigureAwait(false);
Expand All @@ -206,7 +203,9 @@ public async Task<MsalTokenResponse> SignInInteractivelyAsync(
using LogEventWrapper logEventWrapper = new LogEventWrapper(this);
MsalTokenResponse msalTokenResponse = null;
var cancellationToken = authenticationRequestParameters.RequestContext.UserCancellationToken;
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if msal runtime init failed");
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if MSAL runtime init failed");

_logger?.Info($"[RuntimeBroker] Calling SignInInteractivelyAsync this will show the account picker.");

using (var authParams = WamAdapters.GetCommonAuthParameters(
authenticationRequestParameters,
Expand All @@ -224,7 +223,7 @@ public async Task<MsalTokenResponse> SignInInteractivelyAsync(
loginHint,
cancellationToken).ConfigureAwait(false))
{
var errorMessage = "Could not login interactively.";
var errorMessage = "Could not sign in interactively.";
msalTokenResponse = WamAdapters.HandleResponse(result, authenticationRequestParameters, _logger, errorMessage);
}
}
Expand All @@ -237,7 +236,7 @@ public async Task<MsalTokenResponse> AcquireTokenInteractiveDefaultUserAsync(
AcquireTokenInteractiveParameters acquireTokenInteractiveParameters)
{
using LogEventWrapper logEventWrapper = new LogEventWrapper(this);
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if msal runtime init failed");
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if MSAL runtime init failed");

MsalTokenResponse msalTokenResponse = null;
var cancellationToken = authenticationRequestParameters.RequestContext.UserCancellationToken;
Expand All @@ -255,7 +254,7 @@ public async Task<MsalTokenResponse> AcquireTokenInteractiveDefaultUserAsync(
authenticationRequestParameters.CorrelationId.ToString("D"),
cancellationToken).ConfigureAwait(false))
{
var errorMessage = "Could not login interactively with the Default OS Account.";
var errorMessage = "Could not sign in interactively with the default OS account.";
msalTokenResponse = WamAdapters.HandleResponse(result, authenticationRequestParameters, _logger, errorMessage);
}
}
Expand All @@ -278,7 +277,7 @@ public async Task<MsalTokenResponse> AcquireTokenSilentAsync(
AcquireTokenSilentParameters acquireTokenSilentParameters)
{
using LogEventWrapper logEventWrapper = new LogEventWrapper(this);
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if msal runtime init failed");
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if MSAL runtime init failed");

var cancellationToken = authenticationRequestParameters.RequestContext.UserCancellationToken;
MsalTokenResponse msalTokenResponse = null;
Expand Down Expand Up @@ -326,7 +325,7 @@ public async Task<MsalTokenResponse> AcquireTokenSilentDefaultUserAsync(
AcquireTokenSilentParameters acquireTokenSilentParameters)
{
using LogEventWrapper logEventWrapper = new LogEventWrapper(this);
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if msal runtime init failed");
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if MSAL runtime init failed");

var cancellationToken = authenticationRequestParameters.RequestContext.UserCancellationToken;
MsalTokenResponse msalTokenResponse = null;
Expand Down Expand Up @@ -387,7 +386,7 @@ public async Task<MsalTokenResponse> AcquireTokenByUsernamePasswordAsync(
public async Task RemoveAccountAsync(ApplicationConfiguration appConfig, IAccount account)
{
using LogEventWrapper logEventWrapper = new LogEventWrapper(this);
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if msal runtime init failed");
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if MSAL runtime init failed");

if (account == null)
{
Expand Down Expand Up @@ -457,7 +456,7 @@ public async Task<IReadOnlyList<IAccount>> GetAccountsAsync(
return Array.Empty<IAccount>();
}
using LogEventWrapper logEventWrapper = new LogEventWrapper(this);
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if msal runtime init failed");
Debug.Assert(s_lazyCore.Value != null, "Should not call this API if MSAL runtime init failed");

var requestContext = cacheSessionManager.RequestContext;

Expand Down Expand Up @@ -536,25 +535,25 @@ public bool IsBrokerInstalledAndInvokable(AuthorityType authorityType)
{
if (!DesktopOsHelper.IsWin10OrServerEquivalent())
{
_logger?.Warning("[WAM Broker] Not a supported operating system. WAM broker is not available. ");
_logger?.Warning("[RuntimeBroker] Not a supported operating system. WAM broker is not available. ");
return false;
}

// WAM only works with AAD
if (authorityType != AuthorityType.Aad)
{
_logger?.Warning($"[WAM Broker] Authority is {authorityType}. WAM is not available");
_logger?.Warning($"[RuntimeBroker] Authority is {authorityType}. WAM is not available");
return false;
}

if (s_lazyCore.Value == null)
{
_logger?.Info(() => "[WAM Broker] MsalRuntime initialization failed. See https://aka.ms/msal-net-wam#wam-limitations");
_logger?.Info(() => "[RuntimeBroker] MsalRuntime initialization failed. See https://aka.ms/msal-net-wam#wam-limitations");
_logger?.InfoPii(s_initException);
return false;
}

_logger?.Verbose(() => "[WAM Broker] MsalRuntime initialization successful.");
_logger?.Verbose(() => "[RuntimeBroker] MsalRuntime initialization successful.");
return true;
}

Expand Down