Redact SQLAlchemy bind params, attach SQL context to errors, add RFC8523 JTI replay and tests#4862
Conversation
…y/2026-02-05-2izwhl
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3ba7a96a3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| _purge_expired_jtis(current_time, max_age_seconds) | ||
| if jti in _JTI_CACHE: | ||
| return True | ||
| if current_time - iat <= max_age_seconds: | ||
| _JTI_CACHE[jti] = iat |
There was a problem hiding this comment.
Cache JTIs for skew-allowed tokens
Because validate_enhanced_jwt_bearer allows tokens up to max_age_seconds + clock_skew_seconds old, a token with age just over max_age_seconds still passes validation, but is_jwt_replay won’t cache it due to the stricter current_time - iat <= max_age_seconds check. That means reusing the same token within the skew window won’t be detected as a replay. Consider caching JTIs for the full validation window (e.g., include skew or pass the effective max age) so second use of an otherwise valid token is rejected.
Useful? React with 👍 / 👎.
…y/2026-02-05-2izwhl
Motivation
authn.tenants) exist during tests.Description
_format_sqlalchemy_error_data,_safe_params_metadata, and_looks_like_validation_errorhelpers totigrbl/runtime/errors/utils.pyand exported them for use by the error conversion layer.tigrbl/runtime/errors/converters.pyto recognizeStatementErrorand to include SQL context or safe redaction metadata forStatementError,OperationalError, andDBAPIErrorwhen appropriate._JTI_CACHEwith locking and expiry logic intigrbl_auth/rfc/rfc8523.pyand invoked replay detection insidevalidate_enhanced_jwt_bearer.pkgs/standards/tigrbl_tests/tests/i9n/test_sqlalchemy_error_redaction_uvicorn.pyandpkgs/standards/tigrbl_tests/tests/unit/runtime/test_error_sqlalchemy_context.py) and extended RFC8523 tests to assert JTI replay behavior (pkgs/standards/tigrbl_auth/tests/unit/test_rfc8523_jwt_client_auth.py).authnschema inpkgs/standards/tigrbl_auth/tests/conftest.pyand cleaning it up after the engine is disposed so schema-qualified inserts succeed.Testing
uv run --directory pkgs/standards/tigrbl_auth --package tigrbl-auth ruff format .which completed successfully.uv run --directory pkgs/standards/tigrbl_auth --package tigrbl-auth ruff check . --fixwhich reportedAll checks passed!.tigrbl_authtest suite withuv run --package tigrbl-auth --directory standards/tigrbl_auth pytestand observed388 passed, 5 skipped, 83 deselected(all tests in that run passed).pkgs/standards/tigrbl_tests; those tests were added but not executed as part of thetigrbl_authpytest run above.Codex Task