Conversation
commit_table bound self._session.headers and wrote the table's token into it, so the token outlived the commit and was sent with later requests for other tables. Build the request headers from a copy instead; the request itself is unchanged.
|
Closing this in favour of #3976, which was opened two days earlier and covers I missed #3976 when I checked for existing work: it links the issue from its body No objection to #3976's approach — applying the table token through a |
Addresses the first half of #3970.
Rationale for this change
RestCatalog.commit_tablebound the session's own header mapping and then wrotethe table-scoped token into it:
self._sessionis shared by every table the catalog serves, so the assignmentoutlives the commit. The token stays on the session and is carried by later
requests, including requests for other tables.
headersis already passed explicitly toself._session.post(...), so buildingit from a copy sends exactly the same request while leaving the session alone.
Are these changes tested?
Yes —
test_commit_table_does_not_leak_table_token_onto_sessionintests/catalog/test_rest.pyloads a table whose config carries a token, commits,and asserts the session has no
Authorizationheader afterwards. Onmaintheassertion fails, because the session is left holding
Bearer table_scoped_token.tests/catalog/test_rest.pypasses (166 passed; the one unrelated failure,test_rest_catalog_with_google_credentials_path, is a missing optionalgoogledependency in my environment and fails identically on
main).Are there any user-facing changes?
No. The request the catalog sends is unchanged; only the lifetime of the header
changes.
Left out of this PR
Two related findings, kept separate so this stays one concern:
all.
RestCatalogsetssession.auth = AuthManagerAdapter(...), andrequestsappliessession.authafter per-request headers are merged, so theauth manager overwrites
Authorization. Both before and after this change, thecommit goes out with the catalog's token. I have written this up on Per-catalog auth state is shared: commit_table mutates the session, and cached S3FileSystem instances share a signer #3970
rather than change it here, because deciding whether a table-scoped token
should override the auth manager is a design question.
S3FileSystemsigner sharing described in the second half of Per-catalog auth state is shared: commit_table mutates the session, and cached S3FileSystem instances share a signer #3970 isuntouched; it is also commented on the issue.