Skip to content

[Bug]: userinfo endpoint returns outdated roles #2640

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

Closed
darioielardi opened this issue Feb 6, 2024 · 7 comments
Closed

[Bug]: userinfo endpoint returns outdated roles #2640

darioielardi opened this issue Feb 6, 2024 · 7 comments
Assignees

Comments

@darioielardi
Copy link

darioielardi commented Feb 6, 2024

What happened?

After changing, for example, the user full name or first name or any other user detail from the FusionAuth UI, if I then hit the userinfo endpoint, I get back the updated data. But if I change any user registration to add or remove any role and then hit the userinfo endpoint, I get the old roles array. I need to logout, get a new token, call the userinfo endpoint again, and then the roles array will be correct. It seems like the roles array is retrieved from the token sent with the request rather than fetching the updated one.

Version

1.40.2

Affects Versions

No response

Related

@robotdan robotdan added the enhancement New feature or request label Feb 7, 2024
@robotdan
Copy link
Member

robotdan commented Feb 7, 2024

Currently the UserInfo endpoint is returning you the roles claim from the provided access token. (JWT).

We could optionally return you the current roles instead of what is in the JWT. On one hand this seems more correct, but if you are using the UserInfo response to identify the current state of the access token (JWT) then it isn't as ideal.

Internal:

  • Let's review this endpoint and in context of any changes that are coming for the custom scopes feature and see if the current behavior is as correct as it could be.

@darioielardi
Copy link
Author

Currently the UserInfo endpoint is returning you the roles claim from the provided access token. (JWT).

We could optionally return you the current roles instead of what is in the JWT. On one hand this seems more correct, but if you are using the UserInfo response to identify the current state of the access token (JWT) then it isn't as ideal.

Internal:

  • Let's review this endpoint and in context of any changes that are coming for the custom scopes feature and see if the current behavior is as correct as it could be.

My thoughts exactly, I was wondering if there could be something like a param to configure the endpoint behavior. I'll wait for updates, thank you.

@robotdan
Copy link
Member

After review this internally, I think the current behavior is correct, or at least it is the intended behavior.

The reason for this behavior is that we are only returning claims that exist in the access token in order to represent the current state of the access token, or what the user would have access to if you provided your service with this token.

So for the roles claim specifically, the only reason this claim is returned on this endpoint is because it exists in the access token, and we would not want to mutate this claim to be different that what was true when the access token was created and signed.

In any upcoming release we will be expanding our support for scopes. Specifically allow you to define custom scopes and then allowing the UserInfo endpoint to respond to those scopes using a lambda function.

This means, for your specific use case, if you do actually want the most current value for the roles claim, you could optionally update this claim using the lambda function. @darioielardi does this seem like a reasonable solution to you?

@robotdan robotdan added working as designed and removed enhancement New feature or request labels Feb 22, 2024
@robotdan robotdan self-assigned this Feb 22, 2024
@darioielardi
Copy link
Author

@robotdan Sorry for the long wait, I missed your reply somehow.

I understand the reasoning behind your decision, it totally makes sense.
I'm not sure I understand your last point tho, what do you mean by "update this claim using the lambda function"?

@mooreds
Copy link
Collaborator

mooreds commented May 16, 2024

I think he means to use the JWT populate lambda which can read roles from the registration and put them into the JWT.

@andrewpai
Copy link

We released support for custom OAuth scopes in version 1.50.0, and along with that came a new Userinfo Populate Lambda, which you can use to customize the response of the /oauth2/userinfo endpoint.

We are going to leave the default behavior as it is, as reflecting the validated claims is the intent of our current implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants