-
Notifications
You must be signed in to change notification settings - Fork 1
fix: session-cookie requests partition the response cache without a bearer #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5965,10 +5965,21 @@ def _authorize( | |
| self._authorized_purpose = effective_purpose | ||
|
|
||
| def _cache_partition(self) -> str: | ||
| """Return a non-secret cache partition for the authenticated bearer.""" | ||
| """Return a non-secret cache partition for the authenticated principal. | ||
|
|
||
| Bearer-authenticated callers partition by their bearer token. | ||
| Browser admin sessions authenticate without a bearer header, so an | ||
| active opaque session id partitions those requests instead — the | ||
| session id is random per login, so cross-session cache reuse stays | ||
| impossible while cookie-authenticated operators still get hits | ||
| within their own session. | ||
| """ | ||
| raw = self.headers.get("authorization", "") | ||
| token = raw.split(" ", 1)[1].strip() if raw.lower().startswith("bearer ") else "" | ||
| if not token: # pragma: no cover - _authorize rejects this first | ||
| if not token: | ||
| session_id = security._extract_admin_session_cookie(self.headers) | ||
| if session_id and security._admin_session_is_active(session_id): | ||
| return hashlib.sha256(f"admin-session:{session_id}".encode("utf-8")).hexdigest() | ||
| raise RequestError(401, "unauthorized", "bearer token is required") | ||
| return hashlib.sha256(token.encode("utf-8")).hexdigest() | ||
|
Comment on lines
5977
to
5984
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Bearer/session priority differs between authorize and partitioner
Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.