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

fix(jwt): issue with removing leading slash from keys in user object #228

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mirko-pira
Copy link

🔧 fix:
Improved the JWT namespace handling within the "fastify-user" plugin to effectively trim any leading slashes from the key. This update addresses cases where the namespace was defined without a trailing slash, which previously resulted in keys beginning with an unintended leading slash. Now, the keys are normalized by removing these leading slashes.

💡refactor:
The logic for processing the JWT namespace has been refined to automatically remove leading slashes from keys whenever the namespace does not end with a slash. This ensures that keys are consistently formatted without any leading slashes, enhancing system reliability and preventing misrouting or path errors in applications.

🔎 Use-case:
Before this update, defining a JWT namespace without a trailing slash led to keys with a leading slash, causing potential misconfigurations in route handling or session management. With the current enhancement, the JWT namespace is sanitized by automatically trimming leading slashes, ensuring that the keys are correctly formatted for seamless integration and operation within the system. This change boosts the robustness of namespace handling, eliminating common errors related to slash misplacement.

…taNoNamespace object

The change in the code ensures that the leading slash is removed from the keys in the userDataNoNamespace object. This fix addresses a bug where keys were not being processed correctly, leading to incorrect data manipulation.
@mirko-pira mirko-pira changed the title 🐛 (jwt.js): fix issue with removing leading slash from keys in user object fix(jwt): issue with removing leading slash from keys in user object Apr 25, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Thanks for opening a PR! Can you please add a unit test?

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

Successfully merging this pull request may close these issues.

None yet

2 participants