Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[msal-node][#2] Merge cache logic in msal-common for node and browser platforms #1762

Merged
merged 33 commits into from Jun 17, 2020

Conversation

sameerag
Copy link
Member

@sameerag sameerag commented Jun 8, 2020

This PR merges the cache operations for node and browser platforms. It:

  • Rewrites storing cache with redefined API`s for browser with the new Cache format
  • Updates SPAClient to consume the new APIs
  • Remove old cache references for browser and SPA Client

cc @pkanher617

@github-actions github-actions bot added msal-browser Related to msal-browser package msal-common Related to msal-common package labels Jun 8, 2020
@sameerag sameerag changed the base branch from msal-node-cache-silentFlow to dev June 8, 2020 22:55
@sameerag sameerag changed the base branch from dev to msal-node-cache-silentFlow June 8, 2020 22:56
sameerag added a commit that referenced this pull request Jun 9, 2020
@sameerag sameerag changed the base branch from msal-node-cache-silentFlow to dev June 9, 2020 22:39
@sameerag sameerag changed the base branch from dev to msal-node-cache-silentFlow June 9, 2020 22:40
@pkanher617 pkanher617 marked this pull request as ready for review June 11, 2020 00:55
@pkanher617 pkanher617 changed the title [msal-mode] Merge cache logic in msal-common for node and browser platforms [msal-node][#2] Merge cache logic in msal-common for node and browser platforms Jun 11, 2020
const itemCookie = this.getItemCookie(msalKey);
if (this.cacheConfig.storeAuthStateInCookie && itemCookie) {
return itemCookie;
getItem(key: string, type: string): string | object {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per discussion with @pkanher617, instead of baking this business logic into these functions, you should instead create an abstract class with functions for each of the case statements, and then have BrowserStorage implement ICacheStorage and extend the abstract class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That way consumers can use a use-case specific function instead of passing a magic string, and that way if applications provide their own storage implementations, they don't have to know about this logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will revisit this when we add the feature for consumer driven storage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have consumer driven storage for Node that we want to support (the extensions library).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sameerag @pkanher617 Let's talk about this next design meeting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have other storage scenarios for the web such as VS code extensions that we will want to support, which would fall under "user-provided storage"

Copy link
Member Author

@sameerag sameerag Jun 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The abstract class is now implemented in the follow up PR #1771. Regarding abstracting getItem implementation, I agree we can improve it for custom storage, however I would like to track it separately and as an enhancement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can prioritize if we can arrive at a design soon but considering the timelines to get a working branch earlier, I would like to close this PR.

lib/msal-common/src/client/SilentFlowClient.ts Outdated Show resolved Hide resolved
samples/VanillaJSTestApp2.0/app/default/auth.js Outdated Show resolved Hide resolved
lib/msal-browser/src/cache/BrowserStorage.ts Show resolved Hide resolved
lib/msal-browser/src/app/PublicClientApplication.ts Outdated Show resolved Hide resolved
@pkanher617 pkanher617 changed the base branch from msal-node-cache-silentFlow to dev June 17, 2020 16:55
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 77.575% when pulling e80a2ed on msal-node-cache-merge into 189cbe7 on dev.

@pkanher617 pkanher617 merged commit c968ef7 into dev Jun 17, 2020
@pkanher617 pkanher617 deleted the msal-node-cache-merge branch June 17, 2020 23:15
@sameerag sameerag mentioned this pull request Jun 24, 2020
1 task
azure-pipelines bot pushed a commit to pkanher617/microsoft-authentication-library-for-js that referenced this pull request Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msal-browser Related to msal-browser package msal-common Related to msal-common package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants