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

Protected resource map fix by sequencing matching protected resources keys #7274

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from

Conversation

abhixkj
Copy link

@abhixkj abhixkj commented Aug 25, 2024

Fixes
#7173
and retains the fix for
#7111

@github-actions github-actions bot added the msal-angular Related to @azure/msal-angular package label Aug 25, 2024
@abhixkj
Copy link
Author

abhixkj commented Aug 25, 2024 via email

@abhixkj
Copy link
Author

abhixkj commented Sep 3, 2024

Hi @jo-arroyo can you please review the changes when you have some time, I have fixed the #7111 issue using a different method so that the subsequent issue #7173 doe not happen.

// Storing the resource with the index position in the endpoint URL
if (StringUtils.matchPattern(normalizedKey, normalizedEndpoint)) {
const indexn = endpoint.indexOf(normalizedKey);
absoluteResourcesWithIndex.set(key, Math.max(0, indexn));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why Math.max here instead of directly using indexn? What's the scenario where indexn is < 0?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also don't quite understand what's happening here w.r.t. index. Why are you looking for the index of the key, then later sorting by index? I see comments around what is happening but it would be helpful to also include comments about why

Copy link
Author

@abhixkj abhixkj Sep 22, 2024

Choose a reason for hiding this comment

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

In issue #7111 , the user had reported a sample request like
https://MY_API_SITE_1/api/sites?$filter=siteUrl eq 'https://MY_API_SITE_2'
which was failing, so this logic matches the pattern for key in the URL and tries to pick the first match, I am just storing the index as 0 if no match found. All this logic to handle the request mentioned in #7111. It was difficult to explain in comments as these requests with kind of sub URL is rare. Hope you could help me with the comments.
You may check the test cases added by jo-arroyo for #7111 fix. this logic targets that fix in a way such that it does not break existing matching logic with path-scopes matching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
msal-angular Related to @azure/msal-angular package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants