Skip to content

Commit 9e4e5f2

Browse files
committed
fix(oauth): prove the new Atlassian grant is saved and note the site limit
1 parent fab9bc7 commit 9e4e5f2

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

‎apps/docs/content/docs/search/connect-your-account.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ After your admin adds a source in **Settings → Sources**, connect your own acc
2525
To connect another account of the same app, such as Google Drive for two different work accounts, open the app and choose **Add account**, then pick the other account when the provider asks. You can connect up to five accounts per app, and Search looks across all of them. Open an account to see its tool permissions when the app supports them; each account's menu has **Reconnect** and **Disconnect**.
2626

2727
- Slack accounts must belong to your organization's connected workspace.
28-
- For another Confluence or Jira site on the same Atlassian login, choose **Add account** or **Reconnect** and pick the site. The site joins your existing account, and Search covers every site that login can reach.
28+
- For another Confluence or Jira site on the same Atlassian login, choose **Add account** or **Reconnect** and pick the site. The site joins your existing account. Search reads up to four sites per Atlassian account in one search and notes when it leaves sites out.
2929
- Each Notion workspace is its own account, so add one per workspace. If Sim asks you to reconnect first, reconnect your existing Notion account once, then add the other workspace.
3030
- Zoom, Lucid, and Databricks allow one account, because Sim cannot yet tell their accounts apart.
3131
- If the provider signs you straight back into a connected account, sign in to the other account with the provider first, then choose **Add account** again.

‎apps/sim/lib/credential-groups/__integration__/multiple-provider-accounts.integration.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ vi.mock('@/lib/credential-groups/scoped-availability', () => ({
3939
isScopedCredentialGroupsAvailable: async () => true,
4040
}))
4141

42+
/** Each grant carries its own token, as a real exchange does, so a saved grant is identifiable. */
43+
let grants = 0
44+
4245
vi.mock('@/lib/credential-groups/provider-registry', async (importOriginal) => {
4346
const { getCredentialGroupProviderId } = await import('@/lib/credential-groups/providers')
4447
return {
@@ -61,7 +64,7 @@ vi.mock('@/lib/credential-groups/provider-registry', async (importOriginal) => {
6164
providerTenantId: tenant || null,
6265
displayName: code,
6366
metadata: { email: code },
64-
accessToken: `token-for-${code}`,
67+
accessToken: `token-for-${code}-${(grants += 1)}`,
6568
grantedScopes: POLICY.requiredScopes,
6669
accessTokenExpiresAt: null,
6770
refreshTokenExpiresAt: null,
@@ -253,7 +256,7 @@ describe('connecting several accounts of one provider', () => {
253256
status: 'active',
254257
})
255258
expect(await decryptManagedOAuthTokenSet(stored?.tokens ?? '')).toMatchObject({
256-
accessToken: 'token-for-work@second-tenant.test',
259+
accessToken: expect.stringMatching(/^token-for-work@second-tenant\.test-/),
257260
})
258261
})
259262

@@ -342,14 +345,16 @@ describe('reconnecting one of several accounts', () => {
342345
describe('adding another site to an Atlassian login', () => {
343346
it('keeps the new grant on the existing account instead of refusing it', async () => {
344347
const first = await connect('person@atlassian', { kind: 'create' }, CONFLUENCE)
345-
const [before] = await rows()
348+
const saved = async () =>
349+
(await decryptManagedOAuthTokenSet((await rows())[0]?.tokens ?? '')).accessToken
350+
const firstToken = await saved()
346351

347352
const added = await connect('person@atlassian', { kind: 'create' }, CONFLUENCE)
348353

349354
expect(added).toMatchObject({ created: false, credentialId: first.credentialId })
350-
const after = await rows()
351-
expect(after).toHaveLength(1)
352-
expect(after[0]?.tokens).not.toBe(before?.tokens)
355+
expect(await rows()).toHaveLength(1)
356+
expect(await saved()).toMatch(/^token-for-person@atlassian-/)
357+
expect(await saved()).not.toBe(firstToken)
353358
})
354359

355360
it('still adds a different Atlassian login as its own account', async () => {

‎apps/sim/lib/credential-groups/providers.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,12 @@ export function getCredentialGroupProviderService(
272272
return service
273273
}
274274

275+
/** Whether connecting the same login again refreshes its existing account, adding sites to it. */
275276
export function credentialGroupGrantSpansSites(provider: CredentialGroupProvider): boolean {
276277
return CREDENTIAL_GROUP_PROVIDER_SUPPORT[provider].grantSpansSites === true
277278
}
278279

280+
/** Whether an account saved without a tenant may take one on when the same person reconnects. */
279281
export function credentialGroupTenantRecordedLater(provider: CredentialGroupProvider): boolean {
280282
return CREDENTIAL_GROUP_PROVIDER_SUPPORT[provider].tenantRecordedLater === true
281283
}

0 commit comments

Comments
 (0)