Reject invalid personal access token expiration before issuance - #1084
Open
Floating-Y wants to merge 1 commit into
Open
Floating-Y wants to merge 1 commit into
Floating-Y wants to merge 1 commit into
Conversation
Signed-off-by: Floating-Y <118035379+Floating-Y@users.noreply.github.com>
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.
Why
POST /api/v1/me/tokenssilently treats negativeexpires_in_daysvalues as permanent tokens. Large positive values can also panic when constructing a duration or adding it to the current date. Invalid expiration requests should return a validation error before issuing a token.What changes
AppError::invalidresponse format (HTTP 422, codebad_token_expiry).Duration::try_daysandchecked_add_signedto handle duration overflow and date overflow separately, before token generation, storage, or thetoken.issuedsuccess audit.0,1,365,-1,i64::MIN,100000000, andi64::MAX, including unchanged token and success-audit counts after each rejected request.How it was checked
cargo test --locked -p utopia-server token_routes -- --nocapture: all four new regression tests passed, including the HTTP/database test against a dedicated PostgreSQL instance withUTOPIA_TEST_REQUIRE_DB=1.cargo fmt --all --check: passed.cargo clippy --workspace --all-targets -- -D warnings: passed.cargo test --workspace --no-fail-fast -- --test-threads=1: completed successfully against a freshly migrated dedicated test database, withUTOPIA_TEST_REQUIRE_DB=1andUTOPIA_TEST_REQUIRE_PDFTOTEXT=1.pnpm install --frozen-lockfileandpnpm buildinweb/: passed.Validation limits: the default parallel workspace run encountered a database deadlock in the existing
failed_fallback_save_never_reports_donechat persistence test; the full serial run passed. Local Windows proxy/localhost connection issues were addressed only in the test environment withNO_PROXY=localhost,127.0.0.1,::1and an IPv4 database address. Six explicitly ignored tests (live OCR/RSS and opt-in delivery regressions) were not run. Unconfigured MySQL, Trino, and WebDAV live-service checks returned early and are not claimed as validated. The relevant PostgreSQL token tests did execute.Before review
git commit -s).cargo fmt --all --checkandcargo clippy --workspace --all-targets -- -D warningspass.--test-threads=1; the parallel-run failure and skipped checks are disclosed above.dev.