You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Refactor][openrouter]: JWT extraction and verification is duplicated between the middleware and _resolve_subject #490
This is security-relevant code, and the two copies have to stay in sync by hand: algorithm list, required claims, header parsing, error types. If someone later adds audience= or leeway= to one and forgets the other, a token could pass the middleware and then fail (or worse, the reverse) in the handler. Every request also verifies the signature twice.
Optionally, have the middleware store the claims on request.state.claims, so _resolve_subject reads them instead of decoding again. This is a pure refactor: the existing JWT tests in test_proxy.py should pass unchanged.
Environment
main @ 10ef629.
Severity
Low — maintainability / defense-in-depth refactor, no behavior change.
I'll extract the token parsing/verification into a shared helper and reuse the claims verified by the middleware in _resolve_subject, so JWT decoding only happens once per request while keeping the existing behavior unchanged.
Activity
MaximGit-tech commentedon Oct 6, 2026
Hi! I'd like to work on this.
I'll extract the token parsing/verification into a shared helper and reuse the claims verified by the middleware in
_resolve_subject, so JWT decoding only happens once per request while keeping the existing behavior unchanged.