Skip to content

TypeError for cached AD FS account in V3 #7269

Open
@gabbsmo

Description

@gabbsmo

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

3.21.0

Wrapper Library

Not Applicable

Wrapper Library Version

0

Public or Confidential Client?

Public

Description

After upgrading from V2 to V3 and added the required initialize() call, handleRedirectPromise() will throw a TypeError. This does not seem to happen with Azure AD accounts.

Error Message

TypeError: Cannot set properties of undefined (setting 'tenantProfiles')
at BrowserCacheManager.updateOutdatedCachedAccount (CacheManager.mjs:568:39)
at BrowserCacheManager.getAccount (BrowserCacheManager.ts:399:21)
at CacheManager.mjs:268:33
at Array.forEach ()
at BrowserCacheManager.getAccountsFilteredBy (CacheManager.mjs:263:24)
at BrowserCacheManager.getAllAccounts (CacheManager.mjs:37:46)
at getAllAccounts (AccountManager.ts:21:41)
at StandardController.getAllAccounts (StandardController.ts:1354:16)
at StandardController.handleRedirectPromiseInternal (StandardController.ts:413:39)
at StandardController.handleRedirectPromise (StandardController.ts:386:33)

MSAL Logs

[Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Verbose - BrowserCrypto: modern crypto interface available
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager - createKeyMaps called.
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Verbose - BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration.
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Trace - initialize called
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Info - Emitting event: msal:initializeStart
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Verbose - Claims-based caching is disabled. Clearing the previous cache with claims
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Trace - Executing function clearTokensAndKeysWithClaims
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getTokenKeys called
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getAccessTokenCredential: cache hit
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Trace - Returning result from clearTokensAndKeysWithClaims
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Info - Emitting event: msal:initializeEnd
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Verbose - handleRedirectPromise called
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Verbose - getAllAccounts called
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:05 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getAccountKeys called
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:09 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getAccount called
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:12 GMT] : [] : @azure/[email protected] : Verbose - updateOutdatedCachedAccount: Found a single-tenant (outdated) account entity in the cache, migrating to multi-tenant account entity
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:12 GMT] : [] : @azure/[email protected] : Trace - BrowserCacheManager.getAccountKeys called
msalServiceProvider.js:63 [Fri, 23 Aug 2024 15:28:12 GMT] : [] : @azure/[email protected] : Verbose - handleRedirectPromise has been called for the first time, storing the promise

Network Trace (Preferrably Fiddler)

N/A since no network traffic with the identity provider at this point.

MSAL Configuration

{
    "auth": {
        "clientId": "SOME_GUID",
        "authority": "https://adfs.contoso/adfs",
        "redirectUri": "https://localhost:44300",
        "navigateToLoginRequestUrl": false,
        "knownAuthorities": [
            "https://adfs.contoso/adfs"
        ],
        "protocolMode": "OIDC"
    },
    "cache": {
        "cacheLocation": "localStorage"
    },
    "system": {
        "loggerOptions": {
            "logLevel": 4
        }
    }
}

Relevant Code Snippets

_msalInstance = new msal.PublicClientApplication(msalConfig);
_loginRedirectPromise = _msalInstance.initialize().then(function () {
    return _msalInstance.handleRedirectPromise();
});

Reproduction Steps

  1. Sign in to SPA running V2 using AD FS
  2. Upgrade to V3 and do the required code changes for the upgrade
  3. Refresh the SPA

Expected Behavior

Attempt to upgrade previously cached AD FS accounts should not fail.

Identity Provider

ADFS

Browsers Affected (Select all that apply)

Edge

Regression

@azure/msal-browser 2.38.3

Source

External (Customer)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋Awaiting response from the MSAL.js teamadfsRelated to ADFSbug-unconfirmedA reported bug that needs to be investigated and confirmedmsal-browserRelated to msal-browser packagepublic-clientIssues regarding PublicClientApplicationsquestionCustomer is asking for a clarification, use case or information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions