Repository navigation
fix(auth): don't re-authenticate a caller-supplied token as the client's user (ISSUE-167) - #508
Merged
Conversation
…t's user (ISSUE-167) On a bare 401, BaseServerClient._async_make_request minted a new token as self.user_id and retried, whatever token was in the headers. A token set with set_bearer_token() for a different user therefore quietly became a token for the client's own user: the portal ran Lineage Explorer queries for a user logged in as Peter as erinoverview. exec_report_spec(token=...) had the same exposure. The client now records who it minted its current token for. The retry runs only when there is no token or the token was minted for self.user_id; an expired caller-supplied token raises PyegeriaUnauthorizedException. EgeriaTech, Egeria and the internal helper clients pass the minting user on to sub-clients, so their own tokens still renew. Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.com> Claude-Session: https://claude.ai/code/session_015pdMuQanRknaXmcpx4LmLb Signed-off-by: Dan Wolfson <dan.wolfson@pdr-associates.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.
Problem
On a bare 401,
BaseServerClient._async_make_requestminted a new token asself.user_id/self.user_pwdand retried, whatever token was in the headers. A token set withset_bearer_token()for a different user therefore quietly became a token for the client's own user, and the request succeeded as that user with no error.user_pwdfalls back tosettings.User_Profile.user_pwd, so a client built without a password was exposed too.Seen in the portal: a user logged in as Peter had Lineage Explorer queries run as
erinoverview. Repro on 6.2.14:MyProfile(view, url, "erinoverview", "secret"), thenset_bearer_token(<expired token>), thenget_my_profile()returns Erin's profile.exec_report_spec(token=..., user=..., user_pass=...)had the same exposure. (The portal already has a workaround on egeria-workspaces branchfix/token-expiry-identity-switch.)Fix
BaseServerClientrecords the user it minted its current token for (_token_minted_for). The constructor andset_bearer_token()set it toNone, because the owner of a caller-supplied token is unknown.self.user_id. An expired caller-supplied token now raisesPyegeriaUnauthorizedException.EgeriaTechandEgeriapass the minting user to their sub-clients, including ones created later. So do the internal helper clients inDataDiscovery,ClassificationExplorer,AutomatedCurationand theformat_set_executorfallback. Their own tokens still renew.PYEGERIA_ISSUES.md.Behaviour change: a token passed to a client's constructor no longer auto-renews on 401. Code that passes an expired token that way now gets an error instead of a token for the configured user.
Tests
tests/micro-tests/test_external_token_no_auth_retry.pyhas 7 tests. Four of them fail on the old code: external token, token minted for another user,set_bearer_tokenafter minting, and an external token onEgeriaTech. The other three cover self-renewal and the no-token case, and pass both before and after.omvs_audit.pyreports the same counts as onmain.🤖 Generated with Claude Code
https://claude.ai/code/session_015pdMuQanRknaXmcpx4LmLb