question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebSite + Distributed caching does not work with B2C

See original GitHub issue

Core Library

MSAL Node (@azure/msal-node)

Core Library Version

1.14.2

Wrapper Library

Not Applicable

Wrapper Library Version

None

Public or Confidential Client?

Confidential

Description

My environment/usage: Confidential client (scoped to request) and auth code flow against Azure B2C. DistributedCachePlugin with redis implementation for ICacheClient - and custom partitionmanager.

After extensive debugging I could see that the NodeStorage internal cache (in-memory) had initially (when a new token is acquired) an entry with authority metadata with key prefix authority-metadata-.

When the cacheplugin is called afterCacheAccess - which in turns asks TokenCache to serialize, this entry is not a part of the state.

If I pick out the internal cache state from NodeStorage for this entry and do my own serialize and add it back into the internal cache on beforeCacheAccess, it works as expected.

Error Message

Symptoms:

  • IdTokenClaims are not populated on e.g. getAccountByHomeId, but no errors propagated
  • acquireTokenSilent fails

Msal Logs

No response

MSAL Configuration

n/a

Relevant Code Snippets

n/a

Reproduction Steps

Use DistributedCachePlugin Fetch an identity token Do a get account and see that idTokensClaims property on the returned account is empty even though it is in the cache

Expected Behavior

The whole story around hooking in external cache/storage in “non-desktop scenarios” is far from optimal. I also had to apply workarounds to detect account removed from in-memory cache to be reflected properly in distributed cache (separate github issue to be created).

Identity Provider

Azure B2C Custom Policy

Browsers Affected (Select all that apply)

None (Server)

Regression

No response

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
derisencommented, Nov 23, 2022

@bgavrilMS @hansenfreddy haven’t run that particular sample against B2C, but the other web app sample that this sample was based on supports B2C, so this is unexpected. @hansenfreddy if your code is based on the sample mentioned, let me try reproducing the issue with it.

0reactions
derisencommented, Dec 12, 2022

Closing this due to inactivity. Let us know if your issue persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When is Distributed Caching For Web Applications Required?
The 4-2-B2C sample app would not work at all. When I went to the default page of this web app, I got that...
Read more >
Implement a Content Delivery Network and Caching - Trailhead
Distributed: Is shared across application nodes to reduce the load on the underlying storage systems. Each application in a cluster issues fewer requests....
Read more >
Enterprise Grade Performance with Distributed Cache - Medium
But the old-school local in-memory cache isn't fit to solve the problem anymore, due to the sheer amount of Front-End servers that these ......
Read more >
What is Caching and How it Works - AWS
A cache miss occurs when the data fetched was not present in the cache. Controls such as TTLs (Time to live) can be...
Read more >
Cache Reports and Dashboards at Scheduled Times
Caching reports and dashboards that require large database queries can significantly improve report performance. ... Using B2C Service.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found