fix(api): enable jsonwebtoken rust_crypto so /api/auth/token stops panicking - #95
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
jsonwebtokenwas bumped to v10, whose default features no longer include a crypto backend (v9 bundledring). With neitherrust_cryptonoraws_lc_rsenabled,encode()panics at runtime instead of returningErr, so the handler aborts mid-request and the API drops the connection on everyPOST /api/auth/token(surfaces as "Empty reply from server" / proxy 504). Found while wiringterminal-monitoragainst a running 0.2.1 build; panic + backtrace is inTermFlow.log.jsonwebtoken = { version = "10", features = ["rust_crypto"] }. The sameencodecall incommands::system::generate_api_tokenis fixed by the same change.hs256_token_encoding_has_a_crypto_provider: signs and validates an HS256 token through the handler's exactencode(Header::default(), …, from_secret)call. Verified it reproduces the production panic on the old feature set and passes with the fix.Note:
rust_cryptoalso 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_providerpasses on this branchCryptoProviderpanic when the feature is removedcurl -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