Skip to content

fix(api): enable jsonwebtoken rust_crypto so /api/auth/token stops panicking - #95

Merged
rockyway merged 1 commit into
developfrom
fix/jsonwebtoken-crypto-provider
Sep 14, 2026
Merged

rockyway merged 1 commit into
developfrom
fix/jsonwebtoken-crypto-provider

Conversation

@rockyway

Copy link
Copy Markdown
Contributor

Summary

  • jsonwebtoken was bumped to v10, whose default features no longer include a crypto backend (v9 bundled ring). With neither rust_crypto nor aws_lc_rs enabled, encode() panics at runtime instead of returning Err, so the handler aborts mid-request and the API drops the connection on every POST /api/auth/token (surfaces as "Empty reply from server" / proxy 504). Found while wiring terminal-monitor against a running 0.2.1 build; panic + backtrace is in TermFlow.log.
  • Fix: jsonwebtoken = { version = "10", features = ["rust_crypto"] }. The same encode call in commands::system::generate_api_token is fixed by the same change.
  • Adds hs256_token_encoding_has_a_crypto_provider: signs and validates an HS256 token through the handler's exact encode(Header::default(), …, from_secret) call. Verified it reproduces the production panic on the old feature set and passes with the fix.

Note: rust_crypto also pulls RSA/ECDSA/Ed25519 crates although only HS256 is used — jsonwebtoken 10 has no HMAC-only feature, so this is the minimal option. Lockfile delta is additions only (30 crates), no existing versions bumped.

Test plan

  • cargo test --lib hs256_token_encoding_has_a_crypto_provider passes on this branch
  • Same test fails with the CryptoProvider panic when the feature is removed
  • After the next app build: curl -X POST http://127.0.0.1:42031/api/auth/token -H 'Content-Type: application/json' -d '{"clientId":"x"}' returns a token JSON instead of an empty reply

…ps panicking

jsonwebtoken 10 ships no crypto backend by default (v9 bundled ring). Without
exactly one of rust_crypto/aws_lc_rs, encode() panics with "Could not
automatically determine the process-level CryptoProvider" instead of returning
Err, so the handler aborted mid-request and the API dropped the connection on
every token request in 0.2.1. Same call shape in commands::system::generate_api_token.

Adds a unit test that signs and validates an HS256 token through the handler's
exact encode call; it reproduces the panic on the old feature set.
@rockyway
rockyway merged commit 68b8fb9 into develop Sep 14, 2026
5 checks passed
@rockyway
rockyway deleted the fix/jsonwebtoken-crypto-provider branch September 14, 2026 23:51
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