Context
- JWT verification in
src/dispatch.rs rebuilds jsonwebtoken::Validation (including algs.to_vec()) and DecodingKey on every authenticated request.
- Route JWT config is static after registration (
RouteEntry in src/state.rs).
Problem
Repeated construction of validation state adds CPU on every JWT-protected route.
Proposed change
- At
add_route / freeze, prebuild and store on RouteEntry:
DecodingKey (or error if secret invalid — already checked at register time)
- frozen
Validation template with algorithms, iss/aud/leeway
- Hot path clones cheap handles or uses
Arc references.
Files
src/state.rs, src/dispatch.rs, src/lib.rs, JWT tests
Acceptance criteria
- JWT auth behaviour unchanged (expired, wrong alg, iss/aud, cookie vs bearer).
- No per-request
Validation::new + full algorithm vec rebuild.
- Existing JWT test suite passes.
Expected low-level impact
Lower CPU on every JWT-authenticated request.
Context
src/dispatch.rsrebuildsjsonwebtoken::Validation(includingalgs.to_vec()) andDecodingKeyon every authenticated request.RouteEntryinsrc/state.rs).Problem
Repeated construction of validation state adds CPU on every JWT-protected route.
Proposed change
add_route/freeze, prebuild and store onRouteEntry:DecodingKey(or error if secret invalid — already checked at register time)Validationtemplate with algorithms, iss/aud/leewayArcreferences.Files
src/state.rs,src/dispatch.rs,src/lib.rs, JWT testsAcceptance criteria
Validation::new+ full algorithm vec rebuild.Expected low-level impact
Lower CPU on every JWT-authenticated request.