Add support for Federated Connection Access Token (#1911) #1921
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📋 Changes
This PR adds support for
getFederatedConnectionAccessToken({ connection: string; login_hint?: string })
, which can be used to obtain federated connection access token using theoauth/token
endpoint.In order to retrieve a federated connection access token, we call
oauth/token
using the following payload:The retrieved token will also be stored in the session store, comparable to regular session information.
Stateless
As the browser has a limit to the size of the cookie, each federated connection access token is stored in its own cookie, using the
__FC_{index}
name.image
When an application needs to us many access tokens, it's recommended to consider using a stateful session store.
Stateful
For the stateful session store, nothing changes other than the fact that the provided SessionData, now has an additional federatedConnectionTokenSets property, being either undefined, or an array of
FederatedConnectionTokenSet
.Just like
getAccessToken()
, the newly addedgetFederatedConnectionAccessToken()
can not write to the cookies when called from a Server Component, and will log a warning when either of these two methods are called from such Server Component.📎 References
N/A
🎯 Testing
I have tested this against the only environment that has the feature enabled, and I ensured the following scenario's:
When not logged in, calling
getFederatedConnectionAccessToken
throws theMISSING_REFRESH_TOKEN
error.When logged in, and no Federated Connection Access Token is in the cache, a call to
oauth/token
is mad, the resulting access token is stored in the stateless or stateful session store and returned.When logged in, and a non expired Federated Connection Access token is in the cache, no call to
oauth/token
is made, and the access token from the cache is returned.When logged in, and an expired Federated Connection Access token is in the cache, a call to
oauth/token
is mad, the resulting access token is stored in the stateless or stateful session store and returned.When logging out, the
__FC cookies
are also removed.