Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion mcp-worker/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,14 @@ export async function authorize(
const clientLogo = client.logoUri || '' // No default logo
const requestedScopes = (c.env.AUTH0_SCOPE || '').split(' ')

// Render the consent screen with CSRF protection
// Render the consent screen with CSRF protection.
//
// The consent page reflects client-supplied metadata (client_name, logo_uri)
// from Dynamic Client Registration. It contains no first-party JavaScript, so
// we lock it down with a strict CSP: `script-src 'none'` blocks every script
// execution path (inline <script>, injected event handlers like onerror/
// onload, etc.) independently of HTML escaping, and frame-ancestors/base-uri/
// object-src close clickjacking and related vectors.
return c.html(
renderConsentScreen({
clientLogo,
Expand All @@ -114,6 +121,11 @@ export async function authorize(
requestedScopes,
transactionState,
}),
200,
{
'Content-Security-Policy':
"script-src 'none'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'",
},
)
}

Expand Down
5 changes: 5 additions & 0 deletions mcp-worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ export default {
defaultHandler: app,
authorizeEndpoint: '/oauth/authorize',
tokenEndpoint: '/oauth/token',
// Enables RFC 7591 Dynamic Client Registration. MCP clients such as
// Claude Code and `mcp-remote` require a `registration_endpoint` in the
// OAuth discovery metadata to obtain a client_id; without it they fail
// with "does not support dynamic client registration". See PR #577.
clientRegistrationEndpoint: '/oauth/register',
tokenExchangeCallback: createTokenExchangeCallback(env),
})

Expand Down
Loading