-
Notifications
You must be signed in to change notification settings - Fork 226
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
Load userinfo without refreshing tokens #846
Comments
Currently |
I may be able to contribute to this, but I think there are several ways to do it. The first two that came to mind are:
I think that some refactor is required, because AFAIU the Let me know if you have a different view on how this may be solved. EDIT: probably we should also take into consideration token refreshing. Right now, since the user is always local, there's no need to refresh the token. Maybe, if the "user info" is loaded remotely, we should handle the "expired tokens" scenario and trigger a silentSignin |
The first open makes most sense. BTW: This library already support silent renewing of the access token / id token, that path also takes into account to load the additional user info if needed via |
I'm struggling to understand the reason behind oidc-client-ts/src/ResponseValidator.ts Line 219 in de93b53
With this, whenever a value change, the claim is transformed into an array and the new value is added to the previous. Besides the feature I'm working on, I think this may already cause problems (probably #790 is due to this). For example, imagine the following scenario:
What is the reason behind this? Changing this behavior is a Breaking Change, so I don't think it can be changed easily, but at the same time we wound need additional parameters and logics to handle a new "overrideClaimsOnRefresh" param (and also knowing which claims should be overwritten and which should be concatenated) |
Agree on that, i saw this as well. That whole code is not optimal as it makes of an none array ( |
Yeah, we can do a "legacyMergeClaimsBehavior" that is defaulted to true in this version and will be set to false in the next. If the new behavior is enabled, I think it should be something like
The first loop is something I'm struggling with. I think it's necessary to handle the scenario where, in the updated data, something has been removed for any reason, but at the same time I fear losing important data that it's not actually "required" by the standard. |
Yes, we should definitely not remove stuff that was present in the initial claims. My understand is that we should preserve initial data and only update, enrich what is new. Important is to keep the data type as is (e.g. previous: object -> merged should be still an object, etc...). The current implementation makes e.g. an string to an array of string, which is very unexpected. Merging:
What i also do not like in that code path is the recursion, maybe we can get ride of it by using a stack-based algorithm (e.g. https://haacked.com/archive/2007/03/04/Replacing_Recursion_With_a_Stack.aspx/). |
@pamapa I agree with you, but what can be considered "initial claim"? If Imagine a scenario where the user "deletes" their profile picture. The claim (obtained via userInfo) should be disappear / be nulled upon refresh... A variant of this scenario is where the user "adds" their profile picture. In the old data there's no claim, but in the new data we will have it.
As per array merging, I don't have a real use case to think about this. Thinking about hypotetical cases, for example "liked profiles on facebook", the array should be replaced. Do you have any scenario where concatenating new values would be better?
I didn't know about stack algorithms, I'll investigate this |
initial claim: what is first coming from the id token, then enriched with the user info, if desired. |
Is work being done or planned for addressing this issue? |
Hey @tbm206 , I started working on the issue but then some other priorities at work happened. I hope to be able to work on this during this week. |
Thanks @marcoreni. Much appreciated |
Hi @marcoreni. I see there was some momentum in the linked PRs? When do you expect the work to be merged? |
This can now be achieved much simpler, when doing something like (un-tested) within a merge request: in UserManager.ts public refreshUserInfo() {
const logger = this._logger.create("refreshUserInfo");
const user = await this._loadUser();
if (user) {
user.profile = await this._client.getUserInfo(user.access_token, user.profile);
await this.storeUser(user);
logger.info("refreshed user info");
return user;
}
logger.info("user not found in storage");
return null;
} To check for |
Is there a way to fetch data from the userinfo endpoint without having to refresh the tokens?
AFAIU the "loadUserInfo" options loads data upon login, but there's no way to force a refresh of the information.
The text was updated successfully, but these errors were encountered: