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

basicAuth Configuration Not Working Properly for Multiple Routes #266

Closed
rathahin opened this issue Oct 26, 2023 · 3 comments · Fixed by #267
Closed

basicAuth Configuration Not Working Properly for Multiple Routes #266

rathahin opened this issue Oct 26, 2023 · 3 comments · Fixed by #267
Labels
bug Something isn't working

Comments

@rathahin
Copy link

Description

I'm experiencing an issue where the basicAuth configuration doesn't work as expected for multiple routes. While it works perfectly for a single route, it fails to operate correctly when more than one route is specified.

Steps to Reproduce

  1. Set the basicAuth configuration to include multiple paths like [ '/e-voucher-uat', '/en/e-voucher-uat', '/ku/e-voucher-uat' ].
  2. Try to access any of the paths.

Expected Behavior

I expect that accessing any of the paths specified in the configuration would require basic authentication.

Actual Behavior

Only the first path in the configuration array (/e-voucher-uat in this case) is requiring basic authentication. Other paths are not prompting for authentication.

Code Snippet (Optional)

Upon checking the basicAuth.mjs file, I noticed that the .some() method is used to check the paths. Here's the relevant code snippet:

basicAuthConfig?.include?.some((el) => !event.path?.startsWith(el))

The .some() method stops iterating as soon as it finds a match, causing only the first path to work as expected.

Environment

  • Nuxt version: 3.5.0
  • nuxt-security: 1.0.0-rc.2

Additional Information

None

Possible Solution

Consider using .forEach() or another looping mechanism that will check all paths before deciding to skip authentication.

@rathahin rathahin added the bug Something isn't working label Oct 26, 2023
@Baroshem
Copy link
Owner

Hey @rathahin

Thanks for this issue! The .some() method is not good here, you are correct.

Would you be maybe interested in creating a Pull Request with your change?

I can provide all help needed :)

@rathahin
Copy link
Author

Okay, let me try.

@Baroshem Baroshem linked a pull request Oct 30, 2023 that will close this issue
6 tasks
@Baroshem
Copy link
Owner

Baroshem commented Nov 2, 2023

Closing as it was released with 1.0.0-rc.3 :)

@Baroshem Baroshem closed this as completed Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants