Loading
Claim OAuth application UID across cells
Related to #562061 (closed)
Rollout: #634688
- MR 1 of 2: gitlab-org/cells/topology-service!585 (merged)
- MR 2 of 2 (this MR)
What does this MR do and why?
- Claims
Authn::OauthApplication#uidin the Topology Service so it is unique across cells. Applications replicate to the global IAM database, whereuidis the primary key (discussion). - Gated by
cells_claims_oauth_applications(beta, off). Enabling it also backfills existing applications through the claims verification worker. - Releases
uidclaims inCleanupDynamicApplicationsWorker, which removes applications withdeleteand so skips the claim callbacks.
How to set up and validate locally
Steps
1. Setup
-
Run the Topology Service from gitlab-org/cells/topology-service!585 (merged):
cd gitlab-topology-service git fetch && git checkout 562061-oauth-application-uid-claim && make generate gdk restart gitlab-topology-service -
In a Rails console, confirm cells is enabled, turn on the flag, and store the shared attributes:
Gitlab.config.cell.enabled # => true Feature.enable(:cells_claims_oauth_applications) attrs = { redirect_uri: 'http://localhost:1234/cb', scopes: 'api', owner: User.first, organization: Organizations::Organization.first } -
Store a helper to read the
uidclaims:claims() { gdk psql -d topology_service -c "SELECT bucket_value, source_type, subject_type, subject_id FROM claims WHERE bucket_type = 21;"; }
2. Creating an application claims its uid
app = Authn::OauthApplication.create!(name: 'Claim test', **attrs)
app.uidclaims
# expected output: one row, bucket_value = app.uid, source_type = 16, subject_type = 1, subject_id = the organization ID3. A uid claimed by another cell is rejected
delete skips callbacks, so the claim stays behind as if another cell owned it:
uid = app.uid
app.delete
Authn::OauthApplication.create!(name: 'Duplicate', uid: uid, **attrs)
# expected output: rejected with "uid has already been taken"4. Destroying an application releases its claim
app = Authn::OauthApplication.create!(name: 'Destroy test', **attrs)
app.destroy!claims
# expected output: no row for the destroyed app's uid5. Existing applications are backfilled
Feature.disable(:cells_claims_oauth_applications)
legacy = Authn::OauthApplication.create!(name: 'Legacy', **attrs)
# the verification worker skips records updated in the last hour
legacy.update_column(:updated_at, 2.hours.ago)claims
# expected output: no row for legacy.uidFeature.enable(:cells_claims_oauth_applications)
Cells::ClaimsVerificationWorker.new.perform('Authn::OauthApplication')claims
# expected output: a row for legacy.uid; the orphaned claim from step 3 is removedMR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Hakeem Abdul-Razak