Fix: DO-11363 missing auth cookies redirect to login, only refresh token on 401 not 403 status#632
Merged
Conversation
6626bfe to
da8ca76
Compare
Collaborator
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
da8ca76 to
911da08
Compare
Collaborator
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Motivation and Context
When a browser session cookie expires and is no longer sent, Dara can receive authenticated API requests with no bearer token and no session cookie. The backend classified that as a
400 bad_request, which the frontend routes to/error?code=400rather than back to login.The client also attempted refresh-token recovery for
403responses. A403means the user is authenticated but not authorized, so refreshing the session is not expected to resolve it and can mask the authorization failure.Implementation Description
Missing auth credentials now return the existing expired-session auth payload with HTTP
401, so the frontend treats the response as an authentication failure and redirects users to login with the correct session-expired reason. MalformedAuthorizationheaders still return400, preserving the bad-request behavior for invalid auth syntax.The HTTP client now attempts
/api/auth/refresh-tokenonly for401responses.403responses are returned to callers for normal auth-error handling without using the refresh token.Backend auth tests cover the missing-credentials path on
/verify-session, update the general protected-endpoint expectation, and keep stale-cookie cleanup behavior aligned with the new status. JS HTTP tests now cover refresh-on-401 and no-refresh-on-403.Any new dependencies Introduced
No new dependencies.
How Has This Been Tested?
cd packages/dara-core && DARA_TEST_FLAG=True poetry run pytest tests/python/test_auth.py -qcd packages/dara-core && pnpm exec vitest run tests/js/http.spec.tsx --reporter=verbosepoetry anthology run lintpoetry anthology run format-checkpnpm lerna run lintpnpm lerna run format:checkgit diff --checkPR Checklist:
Screenshots (if appropriate):
N/A