Skip to content

Commit 89f44ab

Browse files
committed
Fix OAuth implementation issues from code review
- Fix resource URI validation: resource field now points to actual resource server URL - Clean up WWW-Authenticate header: remove OAuth-specific parameters, use Location header instead - Update tests to match new OAuth implementation - Ensure MCP clients can successfully connect to the resource server
1 parent 951e50f commit 89f44ab

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

exercises/99.finished/99.solution/src/client.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ export async function getOAuthAuthorizationServerConfig() {
8282
return result.json()
8383
}
8484

85-
export async function getOAuthProtectedResourceConfig() {
85+
export async function getOAuthProtectedResourceConfig(request: Request) {
8686
// This server is the protected resource server, so we return our own configuration
87+
const resourceServerUrl = new URL(request.url)
88+
resourceServerUrl.pathname = '/mcp' // Point to the MCP endpoint
89+
8790
return {
88-
resource: `${EPIC_ME_SERVER_URL}/mcp`,
91+
resource: resourceServerUrl.toString(),
8992
scopes: ['read', 'write'],
9093
resource_owner: 'epicme',
9194
resource_server: {

exercises/99.finished/99.solution/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default {
8686
}
8787

8888
if (url.pathname === '/.well-known/oauth-protected-resource/mcp') {
89-
const config = await getOAuthProtectedResourceConfig()
89+
const config = await getOAuthProtectedResourceConfig(request)
9090
return Response.json(config)
9191
}
9292

exercises/99.finished/99.solution/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ test('OAuth integration flow works end-to-end', async () => {
134134
expect(
135135
protectedResourceConfig.resource,
136136
'🚨 Resource identifier should be present',
137-
).toBe(`${EPIC_ME_SERVER_URL}/mcp`)
137+
).toBe(`${mcpServerUrl}/mcp`)
138138
expect(
139139
protectedResourceConfig.scopes,
140140
'🚨 Scopes should be present',

0 commit comments

Comments
 (0)