Skip to content
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

Order scopes on save to avoid access token duplication in the cache #4479

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

bgavrilMS
Copy link
Member

@bgavrilMS bgavrilMS commented Dec 21, 2023

Fixes #4474

I verified that I am not touching the hot path (getting token from the cache), the reorder happens on saving token response from HTTP, which is already heavy operation.

@bgavrilMS
Copy link
Member Author

@gladjohn - can I please get a review on this?

Copy link
Contributor

@gladjohn gladjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, but based on this comment from the old code token providers send pre-sorted (alphabetically) scopes, if this is mostly true, then would it be performant to check if scopes are sorted already before sorting them?

@bgavrilMS bgavrilMS merged commit e406a1a into main Jan 4, 2024
6 checks passed
@bgavrilMS bgavrilMS deleted the bogavril/4474 branch January 4, 2024 12:33
@bgavrilMS
Copy link
Member Author

bgavrilMS commented Jan 4, 2024

looks good, but based on this comment from the old code token providers send pre-sorted (alphabetically) scopes, if this is mostly true, then would it be performant to check if scopes are sorted already before sorting them?

The important thing here is that it's not in the hot path - this is only invoked when MSAL saves tokens in its cache, so after calling the STS. This is an expensive operation (>100ms), thwarting a string ordering operation that takes at most 1ms.

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