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
Quite often applications desire the ability to be run multiple times without having to reauthenticate the user on each execution. This requires that data from the original authentication be persisted outside of the application memory, so that it can authenticate silently on subsequent executions. Specifically two pieces of data need to be persisted, the `TokenCache` and the `AuthenticationRecord`.
76
+
Quite often applications desire the ability to be run multiple times without having to re-authenticate the user on each execution.
77
+
This requires that data from credentials be persisted outside of the application memory so that it can authenticate silently on subsequent executions.
78
+
Applications can persist this data using `TokenPersistenceOptions` when constructing the credential, and persisting the `AuthenticationRecord` returned from `Authenticate`.
76
79
77
-
### Persisting the TokenCache
80
+
### Persisting the token cache
78
81
79
-
The `TokenCache` contains all the data needed to silently authenticate, one or many accounts. It contains sensitive data such as refresh tokens, and access tokens and must be protected to prevent compromising the accounts it houses tokens for. The `Azure.Identity` library provides the `PersistentTokenCache` class which by default will protect and persist the cache using available platform data protection.
82
+
The credential handles persisting all the data needed to silently authenticate one or many accounts.
83
+
It manages sensitive data such as refresh tokens and access tokens which must be protected to prevent compromising the accounts related to them.
84
+
By default, the `Azure.Identity` library will protect and cache sensitive token data using available platform data protection.
80
85
81
-
To use the `PersistentTokenCache` to persist the cache of any credential simply set the `TokenCache` option.
86
+
To configure a credential, such as the `InteractiveBrowserCredential`, to persist token data, simply set the `TokenCachePersistenceOptions` option.
The `AuthenticationRecord` which is returned from the `Authenticate` and `AuthenticateAsync`, contains data identifying an authenticated account. It is needed to identify the appropriate entry in the `TokenCache` to silently authenticate on subsequent executions. There is no sensitive data in the `AuthenticationRecord` so it can be persisted in a non-protected state.
98
+
The `AuthenticationRecord` which is returned from the `Authenticate` and `AuthenticateAsync`, contains data identifying an authenticated account.
99
+
It is needed to identify the appropriate entry in the persisted token cache to silently authenticate on subsequent executions.
100
+
There is no sensitive data in the `AuthenticationRecord` so it can be persisted in a non-protected state.
93
101
94
102
Here is an example of an application storing the `AuthenticationRecord` to the local file system after authenticating the user.
95
103
@@ -106,9 +114,10 @@ using (var authRecordStream = new FileStream(AUTH_RECORD_PATH, FileMode.Create,
106
114
}
107
115
```
108
116
109
-
### Silent authentication with AuthenticationRecord and PersistentTokenCache
117
+
### Silent authentication with AuthenticationRecord and TokenCachePersistenceOptions
110
118
111
-
Once an application has persisted both the `TokenCache` and the `AuthenticationRecord` this data can be used to silently authenticate. This example demonstrates an application using the `PersistentTokenCache` and retrieving an `AuthenticationRecord` from the local file system to create an `InteractiveBrowserCredential` capable of silent authentication.
119
+
Once an application has configured a credential to persist token data and an `AuthenticationRecord`, it is possible to silently authenticate.
120
+
This example demonstrates an application setting the `TokenCachePersistenceOptions` and retrieving an `AuthenticationRecord` from the local file system to create an `InteractiveBrowserCredential` capable of silent authentication.
The credential created in this example will silently authenticate given that a valid token for corresponding to the `AuthenticationRecord` still exists in the `TokenCache`. There are some cases where interaction will still be required such as on token expiry, or when additional authentication is required for a particular resource.
138
+
The credential created in this example will silently authenticate given that a valid token for corresponding to the `AuthenticationRecord` still exists in the persisted token data.
139
+
There are some cases where interaction will still be required such as on token expiry, or when additional authentication is required for a particular resource.
0 commit comments