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

feat(jwt): Support custom secret keys for signing JWTs #3546

Merged

Conversation

kaandok
Copy link
Contributor

@kaandok kaandok commented Oct 22, 2024

  • Expanded key type check to include 'secret' for JWT signing. This aligns importPrivateKey method with importPublicKey method for handling "secret" type keys.

  • Added a test case to sign, verify, and decode using a custom secret, ensuring the correct flow and error handling with mismatched keys.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

- Expanded key type check to include 'secret' for JWT signing. This aligns importPrivateKey method with importPublicKey method for handling "secret" type keys.

- Added a test case to sign, verify, and decode using a custom secret, ensuring the correct flow and error handling with mismatched keys.
@kaandok kaandok changed the title Support custom secret keys for signing JWTs feat(jwt): Support custom secret keys for signing JWTs Oct 22, 2024
Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 94.27%. Comparing base (3d8abbc) to head (76660e7).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/utils/jwt/jws.ts 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3546      +/-   ##
==========================================
- Coverage   94.29%   94.27%   -0.02%     
==========================================
  Files         157      157              
  Lines        9499     9501       +2     
  Branches     2761     2744      -17     
==========================================
  Hits         8957     8957              
- Misses        542      544       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/utils/jwt/jws.ts Outdated Show resolved Hide resolved
@yusukebe
Copy link
Member

Hi @kaandok

Nice PR! One thing I've left it as a comment.

@kaandok
Copy link
Contributor Author

kaandok commented Oct 23, 2024

Updated, thank you!

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

@kaandok Thank you for the quick fix. Merging now!

@yusukebe yusukebe merged commit 0a99bd3 into honojs:main Oct 23, 2024
16 checks passed
@kaandok kaandok deleted the jwt-middleware-allow-secret-private-keys branch October 23, 2024 08:59
TinsFox pushed a commit to TinsFox/hono that referenced this pull request Oct 28, 2024
* Support custom secret keys for signing JWTs

- Expanded key type check to include 'secret' for JWT signing. This aligns importPrivateKey method with importPublicKey method for handling "secret" type keys.

- Added a test case to sign, verify, and decode using a custom secret, ensuring the correct flow and error handling with mismatched keys.

* update comment for rejected private key imports
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.

2 participants