(db-authorization): fix a bug in handling jwt namespace option #2355
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The update is designed to streamline and enhance the robustness of the jwt namespace handling mechanism, thereby eradicating any inconsistencies and potential formatting issues that may arise from improper namespace configuration.
Regardless of whether the "authorization" → "jwt" → "namespace" object is assigned a URL with or without a trailing slash, it will now be correctly work.
🔧 fix(db-authorization): Correct the jwt namespace option handling
The jwt namespace option within the authentication configuration now automatically appends a forward slash if missing. This modification ensures a uniform format across the board, eliminating any ambiguity and enhancing the system's reliability when parsing or utilizing the namespace.
💡 refactor(authentication.js): Enforce trailing slash for jwt namespace
The jwt namespace option's handling has been refined to include a trailing slash, if not already present, by modifying the authentication logic. This adjustment guarantees that the namespace is consistently formatted, preventing errors related to incorrect path concatenation or resource identification.
🔎 Use-case:
Previously, developers might encounter issues if the jwt namespace option did not conclude with a forward slash, leading to potential mishandling of resource paths or authorization checks. With the current update, specifying the jwt namespace in the authentication configuration object automatically ensures the inclusion of a trailing slash, thus standardizing the format and eliminating related errors. (check screenshot)