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

[IMP] remove dependency on jwt library #18

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

Conversation

ThanhDodeurOdoo
Copy link
Collaborator

@ThanhDodeurOdoo ThanhDodeurOdoo commented Apr 1, 2025

Instead, it is now a local implementation of JWT, this makes
the server less dependent on external libraries for its security
and removes a potential source of dependency injection.

This commit also removes unnecessary async/await
(the old jsonwebtoken was also used synchronously).

@ThanhDodeurOdoo ThanhDodeurOdoo force-pushed the master-internal-jwt-tso branch 6 times, most recently from 0deba45 to 9d4f078 Compare April 2, 2025 07:04
@ThanhDodeurOdoo ThanhDodeurOdoo added backwards-compatible: old server + new client An outdated server works with an updated client backwards-compatible: new server + old client An updated server works with an outdated client labels Apr 2, 2025
@ThanhDodeurOdoo ThanhDodeurOdoo force-pushed the master-internal-jwt-tso branch 3 times, most recently from 6577df8 to 4750916 Compare April 2, 2025 07:43
@ThanhDodeurOdoo
Copy link
Collaborator Author

@nim-odoo @seb-odoo @alexkuhn

@ThanhDodeurOdoo ThanhDodeurOdoo force-pushed the master-internal-jwt-tso branch 6 times, most recently from 9963efd to 0d8ed3c Compare April 2, 2025 08:34
* @returns {string} - The signed JWT token
* @throws {AuthenticationError}
*/
export function sign(payload, key = jwtKey, { algorithm = ALGORITHM.HS256 } = {}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to bother with all of these params if we're only using the default one?

In particular if ALGORITHM_FUNCTIONS doesn't support any other one anyway?

Copy link
Collaborator

@alexkuhn alexkuhn Apr 2, 2025

Choose a reason for hiding this comment

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

The code is heavily inspired by the lib, IMO this is fine to copy them even if we only have a single algorithm at hand now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I kept them to keep the expected API of JWT functions and to make it more clear in the code what are JWT core features vs parameters, it's also more similar to our python implementation that way

@ThanhDodeurOdoo ThanhDodeurOdoo force-pushed the master-internal-jwt-tso branch 2 times, most recently from b380313 to c0f6aac Compare April 3, 2025 06:37
Instead, it is now a local implementation of JWT, this makes
the server less dependent on external libraries for its security
and removes a potential source of dependency injection.

This commit also removes unnecessary async/await
(the old jsonwebtoken was also used synchronously).
@ThanhDodeurOdoo ThanhDodeurOdoo force-pushed the master-internal-jwt-tso branch from c0f6aac to 01ec896 Compare April 3, 2025 06:46
@ThanhDodeurOdoo
Copy link
Collaborator Author

just added better typing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backwards-compatible: new server + old client An updated server works with an outdated client backwards-compatible: old server + new client An outdated server works with an updated client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants