Repository navigation
Hotfix 8.10.1: Fix MCP sign-in for self-registered clients #2722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ebd50b0
Patch System.Security.Cryptography.Pkcs for .NET advisories (#2662)
ejsmith 0e89db0
Fix build failures from vulnerable MessagePack dependency (#2671)
ejsmith 0d02fc1
Explain OAuth client scope consent errors (#2638)
niemyjski 474c380
Let users grant every scope to self-registered OAuth clients
ejsmith 72186bf
Adapt consent browser tests to the 8.10 application paths
ejsmith f466b97
Keep administrator settings when client metadata changes
ejsmith ba62afc
Fix website build Deno compatibility (#2599)
ejsmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
159 changes: 159 additions & 0 deletions
159
src/Exceptionless.Web/ClientApp/e2e/tests/oauth-consent.e2e.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
|
|
||
| test('AuthorizeConsent_InvalidAndRestartedRequests_UsesOnlyCurrentValidation', async ({ page }) => { | ||
| // Arrange | ||
| const errorDescription = | ||
| 'Scopes not allowed for this application: stacks:write, offline_access. Restart authorization with scopes allowed for this application.'; | ||
| let consentRequests = 0; | ||
| let authorizationRequests = 0; | ||
| let completeStaleConsent: (() => void) | undefined; | ||
| let completeSameQueryConsent: (() => void) | undefined; | ||
| let sameQueryRequests = 0; | ||
| await page.addInitScript(() => window.localStorage.setItem('satellizer_token', 'test-consent-session')); | ||
| // This browser regression exercises the production page and FetchClient with HTTP responses. | ||
| // Service policy and issuance are covered separately by OAuthEndpointTests. | ||
| await page.route('**/api/v2/**', async (route) => { | ||
| const path = new URL(route.request().url()).pathname; | ||
| if (path.endsWith('/users/me')) { | ||
| await route.fulfill({ json: { email_address: 'member@example.test', full_name: 'Member' } }); | ||
| } else if (path.endsWith('/organizations')) { | ||
| await route.fulfill({ json: [{ id: '000000000000000000000001', name: 'Test Organization' }] }); | ||
| } else if (path.endsWith('/oauth/authorize/consent')) { | ||
| consentRequests++; | ||
| const body = route.request().postDataJSON() as { client_id: string; scope: string }; | ||
| if (body.client_id === 'same-query-client') { | ||
| sameQueryRequests++; | ||
| } | ||
| if (body.client_id === 'stale-client' || (body.client_id === 'same-query-client' && sameQueryRequests === 1)) { | ||
| await new Promise<void>((resolve) => { | ||
| if (body.client_id === 'same-query-client') { | ||
| completeSameQueryConsent = resolve; | ||
| } else { | ||
| completeStaleConsent = resolve; | ||
| } | ||
| }); | ||
| await route.fulfill({ json: { error: 'invalid_scope', error_description: 'Stale request error' }, status: 400 }); | ||
| return; | ||
| } | ||
| if (body.scope.includes('stacks:write')) { | ||
| await route.fulfill({ json: { error: 'invalid_scope', error_description: errorDescription }, status: 400 }); | ||
| } else { | ||
| await route.fulfill({ json: { client_name: 'Test Client', required_scopes: ['mcp:read'], scopes: body.scope.split(' ') } }); | ||
| } | ||
| } else if (path.endsWith('/oauth/authorize')) { | ||
| authorizationRequests++; | ||
| await route.fulfill({ json: { error: 'invalid_scope', error_description: errorDescription }, status: 400 }); | ||
| } else { | ||
| await route.abort(); | ||
| } | ||
| }); | ||
|
|
||
| const parameters = new URLSearchParams({ | ||
| client_id: 'test-client', | ||
| code_challenge: 'a'.repeat(43), | ||
| code_challenge_method: 'S256', | ||
| redirect_uri: 'http://localhost/callback', | ||
| resource: 'http://localhost/mcp', | ||
| response_type: 'code', | ||
| scope: 'mcp:read projects:read stacks:read stacks:write events:read offline_access' | ||
| }); | ||
| try { | ||
| // Act | ||
| await page.goto(`/next/oauth/authorize?${parameters}`); | ||
| // Assert | ||
| await expect(page.getByText(errorDescription, { exact: true })).toBeVisible(); | ||
| await expect(page.getByText('Required', { exact: true })).toHaveCount(1); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeDisabled(); | ||
| await expect(page.getByRole('checkbox', { name: /Stacks Write/ })).toBeDisabled(); | ||
| await expect(page.getByRole('checkbox', { name: /Offline Access/ })).toBeDisabled(); | ||
| await expect(page.getByRole('checkbox', { name: 'Test Organization' })).toBeDisabled(); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeDisabled(); | ||
| expect(consentRequests).toBe(1); | ||
| expect(authorizationRequests).toBe(0); | ||
| await page.screenshot({ fullPage: true, path: test.info().outputPath('scope-error.png') }); | ||
|
|
||
| // Act: restart with an allowed request. | ||
| parameters.set('scope', 'mcp:read'); | ||
| await page.goto(`/next/oauth/authorize?${parameters}`); | ||
| // Assert | ||
| await expect(page.getByText('Test Client', { exact: true })).toBeVisible(); | ||
| await expect(page.getByRole('checkbox', { name: 'Test Organization' })).toBeEnabled(); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeEnabled(); | ||
| expect(consentRequests).toBe(2); | ||
| // Act | ||
| await page.getByRole('button', { exact: true, name: 'Approve' }).click(); | ||
| // Assert | ||
| await expect(page.getByText(errorDescription, { exact: true })).toBeVisible(); | ||
| expect(authorizationRequests).toBe(1); | ||
|
|
||
| async function navigateWithQuery() { | ||
| await page.evaluate((href) => { | ||
| document.getElementById('oauth-query-link')?.remove(); | ||
| const link = document.createElement('a'); | ||
| link.id = 'oauth-query-link'; | ||
| link.href = href; | ||
| link.textContent = 'Change authorization request'; | ||
| document.body.append(link); | ||
| }, `/next/oauth/authorize?${parameters}`); | ||
| await page.getByRole('link', { name: 'Change authorization request' }).click(); | ||
| } | ||
|
|
||
| // Act: a new query must clear the preceding request's error. | ||
| parameters.set('scope', 'mcp:read projects:read'); | ||
| await navigateWithQuery(); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeEnabled(); | ||
| // Assert | ||
| await expect(page.getByText(errorDescription, { exact: true })).toHaveCount(0); | ||
| await expect(page.getByRole('checkbox', { name: /Projects Read/ })).toBeEnabled(); | ||
|
|
||
| // Act: hold an obsolete request while navigating to another client. | ||
| parameters.set('client_id', 'stale-client'); | ||
| await navigateWithQuery(); | ||
| await expect.poll(() => Boolean(completeStaleConsent)).toBe(true); | ||
| // Assert | ||
| await expect(page.getByRole('checkbox', { name: /Projects Read/ })).toBeDisabled(); | ||
| await expect(page.getByRole('checkbox', { name: 'Test Organization' })).toBeDisabled(); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeDisabled(); | ||
| parameters.set('client_id', 'test-client'); | ||
| await navigateWithQuery(); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeEnabled(); | ||
| const staleResponse = page.waitForResponse( | ||
| (response) => response.url().endsWith('/oauth/authorize/consent') && response.request().postDataJSON().client_id === 'stale-client' | ||
| ); | ||
| // Act | ||
| completeStaleConsent?.(); | ||
| await (await staleResponse).finished(); | ||
| // Assert | ||
| await expect(page.getByText('Stale request error', { exact: true })).toHaveCount(0); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeEnabled(); | ||
|
|
||
| // Arrange: A1 and A2 have identical queries; URL equality cannot reject A1. | ||
| parameters.set('client_id', 'same-query-client'); | ||
| await navigateWithQuery(); | ||
| await expect.poll(() => Boolean(completeSameQueryConsent)).toBe(true); | ||
| await expect(page.getByRole('checkbox', { name: /Projects Read/ })).toBeDisabled(); | ||
|
|
||
| // Act: navigate A → B → A, letting A2 validate before A1 completes. | ||
| parameters.set('client_id', 'test-client'); | ||
| await navigateWithQuery(); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeEnabled(); | ||
| parameters.set('client_id', 'same-query-client'); | ||
| await navigateWithQuery(); | ||
| await expect.poll(() => sameQueryRequests).toBe(2); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeEnabled(); | ||
| const sameQueryResponse = page.waitForResponse( | ||
| (response) => response.url().endsWith('/oauth/authorize/consent') && response.request().postDataJSON().client_id === 'same-query-client' | ||
| ); | ||
| completeSameQueryConsent?.(); | ||
| await (await sameQueryResponse).finished(); | ||
|
|
||
| // Assert | ||
| await expect(page.getByText('Stale request error', { exact: true })).toHaveCount(0); | ||
| await expect(page.getByRole('checkbox', { name: /Projects Read/ })).toBeEnabled(); | ||
| await expect(page.getByRole('checkbox', { name: 'Test Organization' })).toBeEnabled(); | ||
| await expect(page.getByRole('button', { exact: true, name: 'Approve' })).toBeEnabled(); | ||
| } finally { | ||
| completeSameQueryConsent?.(); | ||
| completeStaleConsent?.(); | ||
| } | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.