Repository navigation
feat(oauth): only the current client's user credentials count, and a failed connect stores nothing (#275) - #875
Merged
Conversation
…failed connect stores nothing (#275) Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
…resh; call fetch_identity directly in the callback Signed-off-by: Alex <[email protected]>
Contributor
There was a problem hiding this comment.
Reviewed head 9d8c509. Both earlier [Recommendation] threads are addressed: Oauth::TokenService.fresh now checks on_other_client? before the expired? return (with a test for an unexpired other-client credential), and the controller calls Oauth::Providers.fetch_identity directly. No new findings.
Signed-off-by: Alex <[email protected]>
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.
What changed
Two gaps in how a person's own account (GitHub, GitLab, Bitbucket) connects through the OAuth engine (#275).
1. Only the current client's credentials count.
OauthCredential.on_other_client/#on_other_client?own the rule. "Current" is theOauthClientwith the issuer and client id the deployment is configured with now (Oauth::Providers.current_client_ref, settings only).*_connections_of, and solatest_*/live_*(profile page,*_user_tokentools, and thepull_request_*write tools acting as a user, which use the same contexts), skip other clients' credentials.refresh_dueandOauth::TokenService.freshskip them too, so they lapse.on_other_gitlab_instanceis folded into this: a changedGITLAB_ENDPOINTchanges the issuer.2. A failed connect stores nothing.
after_connect/record_identity!are replaced by afetch_identity:registry hook that runs with the new access token before anything is stored.upsert_from_token!(identity:)then saves the token and identity in one save.Docs: a note in the three user-identity designs,
oauth-implementation.md, and a newdocs/operations/rotating-oauth-clients.md(rotating a client means people reconnect).Out of scope, unchanged: Sentry, Railway and MCP credentials (the rule is limited to
CLIENT_BOUND_PROVIDERS). No revocation of old-client grants at the provider. No migration.Tests
refresh_due, not refreshed byfresh, deleted on disconnect; first connect with a failing identity fetch stores nothing; reconnect with a failing fetch keeps the previous credential and identity; successful connect stores both.pull_request_acting_as: a write tool acting as a user treats an old-client credential as not connected, for each host.github_current, and the gitlab/bitbucket traits). Some tests now stub the client id they use.How to test:
bin/rails test test/models test/services/oauth test/services/internal_tools test/controllers/web/oauth_controller_test.rb test/services/user_connections_test.rb test/integration/web/profile_connections_test.rb. On staging: connect, disconnect and reconnect GitHub and check a token is handed out.