diff --git a/backend/src/__tests__/oauth-config.test.ts b/backend/src/__tests__/oauth-config.test.ts index 5281581c..5cef9840 100644 --- a/backend/src/__tests__/oauth-config.test.ts +++ b/backend/src/__tests__/oauth-config.test.ts @@ -40,7 +40,7 @@ describe('trusted OAuth client configuration', () => { expect(trustedOAuthClients()).toEqual([ { clientId: 'writing-tools-mindmap', - name: 'Writing Tools Mindmap', + name: 'Mindmap', redirectUris: [PROD_REDIRECT], }, ]); diff --git a/backend/src/__tests__/oauth-provider.integration.test.ts b/backend/src/__tests__/oauth-provider.integration.test.ts index c667c245..13b40a6c 100644 --- a/backend/src/__tests__/oauth-provider.integration.test.ts +++ b/backend/src/__tests__/oauth-provider.integration.test.ts @@ -157,11 +157,21 @@ describe.sequential('OAuth provider (Mindmap client)', () => { const html = await login.text(); expect(html).toContain('Sign in with Google'); expect(html).toContain('oauth_query'); + // Names the requesting trusted client, so the user knows what they're connecting. + expect(loginUrl.searchParams.get('client_id')).toBe(CLIENT_ID); + expect(html).toContain('Mindmap wants to use Thoughtful'); // The resource is part of the signed continuation, not re-added by the page. expect(loginUrl.searchParams.get('resource')).toBe(ORIGIN); expect(loginUrl.searchParams.getAll('ba_param')).toContain('resource'); }); + it('falls back to a generic login prompt for an unknown client_id', async () => { + const login = await app.request(`${ORIGIN}/api/oauth/login?client_id=not-a-client`); + const html = await login.text(); + expect(html).toContain('the app you came from'); + expect(html).not.toContain(''); + }); + it('resumes authorization from the login page once sign-in sets a session', async () => { // The provider's continuation fires on any sign-in that sets a session cookie, // so anonymous sign-in stands in for the Google callback here. diff --git a/backend/src/config.ts b/backend/src/config.ts index d7f27a26..60465066 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -101,7 +101,7 @@ export const trustedOAuthClients = (): TrustedOAuthClient[] => [ { clientId: envString('MINDMAP_OAUTH_CLIENT_ID'), - name: 'Writing Tools Mindmap', + name: 'Mindmap', redirectUris: envList('MINDMAP_OAUTH_REDIRECT_URIS'), }, ].filter((client) => client.clientId && client.redirectUris.length > 0); diff --git a/backend/src/routes/debug.ts b/backend/src/routes/debug.ts index cb751409..b4c656ab 100644 --- a/backend/src/routes/debug.ts +++ b/backend/src/routes/debug.ts @@ -8,7 +8,7 @@ const DEBUG_HTML = ` - Auth Debug — Writing Tools Backend + Auth Debug — Thoughtful backend - Sign in to Writing Tools + Sign in to Thoughtful - Sign in to let the app you came from use Writing Tools AI on your behalf. + ${lede} Sign in with Google
Sign in to let the app you came from use Writing Tools AI on your behalf.
${lede}