Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: guard SCIM token rotation against concurrent clicks
Dannyc5a043d71aa2
diff --git a/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsx b/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsxindex 264ca1ba24..bfbdca76e7 100644--- a/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsx+++ b/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsx@@ -186,6 +186,35 @@ describe("AADSyncSheet SCIM token", () => {expect(container.textContent).not.toContain("token-shown-once");});+ it("does not mint a second token while one rotation is in flight", async () => {+ let release: (v: { token: string }) => void = () => {};+ mocks.rotate.mockReturnValue(+ new Promise<{ token: string }>((resolve) => {+ release = resolve;+ })+ );++ await renderSheet();+ await act(async () => {+ buttonByText("generate-token")?.click();+ });++ // Second click while the first is pending must be ignored: each rotation+ // invalidates the previous token, so racing them can display a dead one.+ await act(async () => {+ buttonByText("generate-token")?.click();+ });+ expect(mocks.rotate).toHaveBeenCalledTimes(1);+ expect(buttonByText("generate-token")?.disabled).toBe(true);++ await act(async () => {+ release({ token: "tok-only-one" });+ });+ expect(tokenInput()?.value).toBe("tok-only-one");+ // Re-enabled once settled, so a later deliberate rotation still works.+ expect(buttonByText("generate-token")?.disabled).toBe(false);+ });+it("hides the rotate control without permission", async () => {mocks.hasRotatePermission = false;await renderSheet();diff --git a/frontend/src/routes/workspace/shared/AADSyncSheet.tsx b/frontend/src/routes/workspace/shared/AADSyncSheet.tsxindex 2e2ca8274c..5c7bc9cf16 100644--- a/frontend/src/routes/workspace/shared/AADSyncSheet.tsx+++ b/frontend/src/routes/workspace/shared/AADSyncSheet.tsx@@ -67,6 +67,10 @@ export function AADSyncSheet({// cleared explicitly — otherwise reopening would redisplay a token that is// supposed to have been shown once.const [mintedToken, setMintedToken] = useState("");+ // Each rotation invalidates the previous token, so two in flight can resolve+ // out of order and leave the admin copying a token the server has already+ // replaced. One at a time.+ const [rotating, setRotating] = useState(false);const handleClose = () => {setMintedToken("");@@ -74,6 +78,8 @@ export function AADSyncSheet({};const handleRotateToken = async () => {+ if (rotating) return;+if (tokenConfigured) {const confirmed = window.confirm(t("settings.members.entra-sync.regenerate-token-warning")@@ -81,6 +87,7 @@ export function AADSyncSheet({if (!confirmed) return;}+ setRotating(true);try {const resp = await workspaceServiceClientConnect.rotateDirectorySyncToken(create(RotateDirectorySyncTokenRequestSchema, {@@ -96,6 +103,8 @@ export function AADSyncSheet({});} catch {// error already shown by the client interceptor+ } finally {+ setRotating(false);}};@@ -186,6 +195,7 @@ export function AADSyncSheet({appearance="outline"size="sm"className="self-start"+ disabled={rotating}onClick={handleRotateToken}>{tokenConfigured