You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: msal-javascript-conceptual/node/MIP-caching.md
+2-8Lines changed: 2 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
title: "Microsoft Authentication Extensions for Node"
2
+
title: "Caching"
3
3
description: The Microsoft Authentication Extensions for Node enables application developers to perform cross-platform token cache serialization and persistence. It gives extra support to the Microsoft Authentication Library for Node (MSAL Node).
4
4
author: henrymbuguakiarie
5
5
manager: CelesteDG
@@ -12,7 +12,7 @@ ms.topic: conceptual
12
12
#Customer intent: As an application developer, I want to learn how to use the Microsoft Authentication Extensions for Node to perform cross-platform token cache serialization and persistence.
13
13
---
14
14
15
-
# Microsoft Authentication Extensions for Node
15
+
# Caching in Microsoft Authentication Extensions for Node
16
16
17
17
The Microsoft Authentication Extensions for Node enables developers to perform cross-platform token cache serialization and persistence to disk. It gives extra support to the Microsoft Authentication Library (MSAL) for Node.
18
18
@@ -91,9 +91,3 @@ The following table provides an explanation for all the arguments for the persis
91
91
| accountName | Specifies the account name to be used on Mac and/or Linux | Mac and Linux |
92
92
| usePlaintextFileOnLinux | The flag to default to plain text on linux if LibSecret fails. Defaults to `false`| Linux |
93
93
94
-
## Next steps
95
-
96
-
For more information about Microsoft Authentication Extensions for Node and MSAL Node, see:
97
-
98
-
-[Microsoft Authentication Extensions for Node](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/extensions/msal-node-extensions)
99
-
-[Microsoft Authentication Library for Node](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-node)
Please note that `msal-node` will _not_ fallback to the non-brokered flow in the event of a failure. In order to avoid unexpected failures in the future, only enable the broker flow in environments which support it (refer to the [Supported Environment](#supported-environment) section above).
45
+
Please note that `msal-node` will _not_ fallback to the non-brokered flow in the event of a failure. In order to avoid unexpected failures in the future, only enable the broker flow in environments which support it.
46
46
47
47
A working sample can be found in the [auth-code-cli-brokered-app sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/auth-code-cli-brokered-app)
Copy file name to clipboardExpand all lines: msal-javascript-conceptual/node/caching.md
+6-8Lines changed: 6 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,12 +74,12 @@ Note that the in-memory cache is not scalable for server-side applications and p
74
74
75
75
## Persistent cache
76
76
77
-
MSAL Node fires events when the in-memory cache is accessed and apps can choose whether to persist the cache (see: [TokenCacheContext](https://azuread.github.io/microsoft-authentication-library-for-js/ref/classes/_azure_msal_common.tokencachecontext.html)) (e.g. to a file, a SQL database and etc.). This constitutes two actions:
77
+
MSAL Node fires events when the in-memory cache is accessed and apps can choose whether to persist the cache (see: [TokenCacheContext](https://azuread.github.io/microsoft-authentication-library-for-js/ref/classes/_azure_msal_node.TokenCacheContext.html)) (e.g. to a file, a SQL database and etc.). This constitutes two actions:
78
78
79
79
1. Load the cache from persistence to MSAL's memory before accessing the cache
80
80
2. If the in-memory cache has changed since last access, save the cache back to persistence
81
81
82
-
For persisting the cache, MSAL accepts a custom cache plugin in [configuration](./configuration.md). This plugin should implement the [ICachePlugin](https://azuread.github.io/microsoft-authentication-library-for-js/ref/interfaces/_azure_msal_common.icacheplugin.html) interface:
82
+
For persisting the cache, MSAL accepts a custom cache plugin in [configuration](./configuration.md). This plugin should implement the [ICachePlugin](https://azuread.github.io/microsoft-authentication-library-for-js/ref/interfaces/_azure_msal_node.ICachePlugin.html) interface:
83
83
84
84
```typescript
85
85
interfaceICachePlugin {
@@ -114,11 +114,11 @@ class MyCachePlugin implements ICachePlugin {
114
114
* If you are developing a public client app, [MSAL Node Extensions](./extensions.md) handles this for you.
115
115
* If you are developing a confidential client app, you should persist the cache via a separate service, since a single, *per-server* cache instance isn't suitable for a cloud environment with many servers and app instances.
116
116
117
-
We strongly recommend to encrypt the token cache when persisting it on disk. For public client apps, this is offered out-of-box with [MSAL Node Extensions](../../../extensions/msal-node-extensions/README.md). For confidential clients however, you are responsible for devising an appropriate encryption solution.
117
+
We strongly recommend to encrypt the token cache when persisting it on disk. For public client apps, this is offered out-of-box with MSAL Node Extensions. For confidential clients however, you are responsible for devising an appropriate encryption solution.
118
118
119
119
## Performance and security
120
120
121
-
On public client apps, [MSAL Node Extensions](../../../extensions/msal-node-extensions/README.md) ensures performance and security for you.
121
+
On public client apps, MSAL Node Extensions ensures performance and security for you.
122
122
123
123
On confidential client apps that handle users (web apps that sign in users and call web APIs, and web APIs calling downstream web APIs), there can be many users active concurrently for a given application. Our recommendation is to serialize one cache blob (see [CacheRecord](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/src/cache/entities/CacheRecord.ts)) per user. This would help with scaling the cache across a distributed system. Use a key for partitioning the cache (*i.e.***partition key**), such as:
124
124
@@ -130,7 +130,7 @@ On confidential client apps that handle users (web apps that sign in users and c
130
130
131
131
### Web apps
132
132
133
-
Since web apps are user-facing and often rely on sessions to keep track of each user, the appropriate partition key for caching is often stored within the session data, and needs to be retrieved before the cache lookup can take place. To help with this, MSAL Node provides the [DistributedCachePlugin](/javascript/api/@azure/msal-node/distributedcacheplugin) class, which implements the [ICachePlugin](https://azuread.github.io/microsoft-authentication-library-for-js/ref/interfaces/_azure_msal_common.icacheplugin.html). An instance of `DistributedCachePlugin` requires:
133
+
Since web apps are user-facing and often rely on sessions to keep track of each user, the appropriate partition key for caching is often stored within the session data, and needs to be retrieved before the cache lookup can take place. To help with this, MSAL Node provides the [DistributedCachePlugin](/javascript/api/@azure/msal-node/distributedcacheplugin) class, which implements the [ICachePlugin](https://azuread.github.io/microsoft-authentication-library-for-js/ref/interfaces/_azure_msal_node.ICachePlugin.html). An instance of `DistributedCachePlugin` requires:
134
134
135
135
* a **client interface** ([ICacheClient](/javascript/api/@azure/msal-node/icacheclient)), which implements `get` and `set` operations on the persistence server (Redis, MySQL etc.).
136
136
* a **partition manager** ([IPartitionManager](/javascript/api/@azure/msal-node/ipartitionmanager)), for reading from and writing to cache with respect to a given **session ID**.
@@ -143,6 +143,4 @@ See the samples below for more about how to handle caching in MSAL Node apps:
143
143
144
144
*[(PCA) Console app using MSAL Node Extensions](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/extensions/samples/msal-node-extensions/index.js)
145
145
*[(PCA) Dektop app using MSAL Node Extensions](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/extensions/samples/electron-webpack)
146
-
*[(CCA) Web app using DistributedCachePlugin](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/auth-code-distributed-cache)
147
-
-[Microsoft Authentication Extensions for Node](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/master/extensions/msal-node-extensions)
148
-
-[Microsoft Authentication Library for Node](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/master/lib/msal-node)
146
+
*[(CCA) Web app using DistributedCachePlugin](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-node-samples/auth-code-distributed-cache)
|`clientId`| App ID of your application. Can be found in your [portal registration](../README.md#prerequisites). | UUID/GUID | None. This parameter is required in order for MSAL to perform any actions. |
86
-
|`authority`| URI of the tenant to authenticate and authorize with. Usually takes the form of `https://{uri}/{tenantid}`(see [Authority](../../msal-common/docs/authority.md)) | String in URI format with tenant - `https://{uri}/{tenantid}`|`https://login.microsoftonline.com/common`|
85
+
|`clientId`| App ID of your application. Can be found in your app registration in the Microsoft Entra admin center[portal registration](../README.md#prerequisites). | UUID/GUID | None. This parameter is required in order for MSAL to perform any actions. |
86
+
|`authority`| URI of the tenant to authenticate and authorize with. Usually takes the form of `https://{uri}/{tenantid}`| String in URI format with tenant - `https://{uri}/{tenantid}`|`https://login.microsoftonline.com/common`|
87
87
|`knownAuthorities`| An array of URIs that are known to be valid. Used in B2C scenarios. | Array of strings in URI format | Empty array `[]`|
88
-
|`cloudDiscoveryMetadata`| A string containing the cloud discovery response. Used in Microsoft Entra scenarios. See [Performance](../../msal-common/docs/performance.md) for more info | string | Empty string `""`|
89
-
|`authorityMetadata`| A string containing the .well-known/openid-configuration endpoint response. See [Performance](../../msal-common/docs/performance.md) for more info | string | Empty string `""`|
90
-
|`clientCapabilities`| Array of capabilities to be added to all network requests as part of the `xms_cc` claims request (see: [Client capability in MSAL](../../msal-common/docs/client-capability.md)) | Array of strings |[]|
88
+
|`cloudDiscoveryMetadata`| A string containing the cloud discovery response. Used in Microsoft Entra scenarios. See [Performance](../browser/performance.md) for more info | string | Empty string `""`|
89
+
|`authorityMetadata`| A string containing the .well-known/openid-configuration endpoint response. See [Performance](../browser/performance.md) for more info | string | Empty string `""`|
90
+
|`clientCapabilities`| Array of capabilities to be added to all network requests as part of the `xms_cc` claims request | Array of strings |[]|
91
91
|`protocolMode`| Enum representing the protocol mode to use. If `"AAD"`, will function on the Microsoft Entra v2 endpoints; if `"OIDC"`, will function on OIDC-compliant endpoints. | string |`"AAD"`|
92
-
|`azureCloudOptions`| A defined set of azure cloud options for developers to default to their specific cloud authorities, for specific clouds supported please refer to the [AzureCloudInstance](aka.ms/msaljs/azure_cloud_instance)|[AzureCloudOptions](https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_common.html#azurecloudoptions)|[AzureCloudInstance.None](msaljs/azure_cloud_instance)|
93
-
|`skipAuthorityMetadataCache`| A flag to choose whether to use the local metadata cache during authority initialization. Metadata cache would be used if no authority metadata is provided in configuration and before a network call for metadata has been made (see [Authority](../../msal-common/docs/authority.md)) | boolean |`false`|
92
+
|`azureCloudOptions`| A defined set of azure cloud options for developers to default to their specific cloud authorities, for specific clouds supported please refer to the [AzureCloudInstance](aka.ms/msaljs/azure_cloud_instance)|[AzureCloudOptions](/javascript/api/@azure/msal-node/#azurecloudoptions)|[AzureCloudInstance.None](msaljs/azure_cloud_instance)|
93
+
|`skipAuthorityMetadataCache`| A flag to choose whether to use the local metadata cache during authority initialization. Metadata cache would be used if no authority metadata is provided in configuration and before a network call for metadata has been made | boolean |`false`|
0 commit comments