File tree Expand file tree Collapse file tree 29 files changed +627
-56
lines changed
01.problem.introspect/src
01.solution.introspect/src
01.problem.validate-scopes/src
01.solution.validate-scopes/src
02.problem.specify-scopes/src
02.solution.specify-scopes/src Expand file tree Collapse file tree 29 files changed +627
-56
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { EPIC_ME_AUTH_SERVER_URL } from './client.ts'
88// - scope: string (space-separated list of scopes)
99// - sub: string (the user id)
1010
11- // 🐨 export an async function called getAuthInfo that accepts the request
11+ // 🐨 export an async function called resolveAuthInfo that accepts the request
1212// 🐨 if the request has an Authorization header, get the token from it
1313// if it doesn't, return null
1414// 🐨 construct a URL pointing to `/oauth/introspection` on the auth server
Original file line number Diff line number Diff line change 77import { McpAgent } from 'agents/mcp'
88import {
99 // 💰 you'll need this:
10- // getAuthInfo ,
10+ // resolveAuthInfo ,
1111 handleOAuthAuthorizationServerRequest ,
1212 handleOAuthProtectedResourceRequest ,
1313 handleUnauthorized ,
Original file line number Diff line number Diff line change @@ -10,8 +10,10 @@ const introspectResponseSchema = z.object({
1010 sub : z . string ( ) ,
1111} )
1212
13- export async function getAuthInfo ( request : Request ) : Promise < AuthInfo | null > {
14- const token = request . headers . get ( 'authorization' ) ?. replace ( / ^ B e a r e r \s + / i, '' )
13+ export async function resolveAuthInfo (
14+ authHeader : string | null ,
15+ ) : Promise < AuthInfo | null > {
16+ const token = authHeader ?. replace ( / ^ B e a r e r \s + / i, '' )
1517 if ( ! token ) return null
1618
1719 const validateUrl = new URL (
Original file line number Diff line number Diff line change 66} from '@modelcontextprotocol/sdk/types.js'
77import { McpAgent } from 'agents/mcp'
88import {
9- getAuthInfo ,
9+ resolveAuthInfo ,
1010 handleOAuthAuthorizationServerRequest ,
1111 handleOAuthProtectedResourceRequest ,
1212 handleUnauthorized ,
@@ -85,7 +85,9 @@ export default {
8585 }
8686
8787 if ( url . pathname === '/mcp' ) {
88- const authInfo = await getAuthInfo ( request )
88+ const authInfo = await resolveAuthInfo (
89+ request . headers . get ( 'authorization' ) ,
90+ )
8991 if ( ! authInfo ) return handleUnauthorized ( request )
9092
9193 const mcp = EpicMeMCP . serve ( '/mcp' , {
Original file line number Diff line number Diff line change @@ -10,8 +10,10 @@ const introspectResponseSchema = z.object({
1010 sub : z . string ( ) ,
1111} )
1212
13- export async function getAuthInfo ( request : Request ) : Promise < AuthInfo | null > {
14- const token = request . headers . get ( 'authorization' ) ?. replace ( / ^ B e a r e r \s + / i, '' )
13+ export async function resolveAuthInfo (
14+ authHeader : string | null ,
15+ ) : Promise < AuthInfo | null > {
16+ const token = authHeader ?. replace ( / ^ B e a r e r \s + / i, '' )
1517 if ( ! token ) return null
1618
1719 const validateUrl = new URL (
Original file line number Diff line number Diff line change 66} from '@modelcontextprotocol/sdk/types.js'
77import { McpAgent } from 'agents/mcp'
88import {
9- getAuthInfo ,
9+ resolveAuthInfo ,
1010 handleOAuthAuthorizationServerRequest ,
1111 handleOAuthProtectedResourceRequest ,
1212 handleUnauthorized ,
@@ -85,7 +85,9 @@ export default {
8585 }
8686
8787 if ( url . pathname === '/mcp' ) {
88- const authInfo = await getAuthInfo ( request )
88+ const authInfo = await resolveAuthInfo (
89+ request . headers . get ( 'authorization' ) ,
90+ )
8991 if ( ! authInfo ) return handleUnauthorized ( request )
9092
9193 const mcp = EpicMeMCP . serve ( '/mcp' , {
Original file line number Diff line number Diff line change @@ -10,8 +10,10 @@ const introspectResponseSchema = z.object({
1010 sub : z . string ( ) ,
1111} )
1212
13- export async function getAuthInfo ( request : Request ) : Promise < AuthInfo | null > {
14- const token = request . headers . get ( 'authorization' ) ?. replace ( / ^ B e a r e r \s + / i, '' )
13+ export async function resolveAuthInfo (
14+ authHeader : string | null ,
15+ ) : Promise < AuthInfo | null > {
16+ const token = authHeader ?. replace ( / ^ B e a r e r \s + / i, '' )
1517 if ( ! token ) return null
1618
1719 const validateUrl = new URL (
Original file line number Diff line number Diff line change 66} from '@modelcontextprotocol/sdk/types.js'
77import { McpAgent } from 'agents/mcp'
88import {
9- getAuthInfo ,
9+ resolveAuthInfo ,
1010 handleOAuthAuthorizationServerRequest ,
1111 handleOAuthProtectedResourceRequest ,
1212 handleUnauthorized ,
@@ -85,7 +85,9 @@ export default {
8585 }
8686
8787 if ( url . pathname === '/mcp' ) {
88- const authInfo = await getAuthInfo ( request )
88+ const authInfo = await resolveAuthInfo (
89+ request . headers . get ( 'authorization' ) ,
90+ )
8991 if ( ! authInfo ) return handleUnauthorized ( request )
9092
9193 const mcp = EpicMeMCP . serve ( '/mcp' , {
Original file line number Diff line number Diff line change @@ -12,8 +12,10 @@ const introspectResponseSchema = z.object({
1212 sub : z . string ( ) ,
1313} )
1414
15- export async function getAuthInfo ( request : Request ) : Promise < AuthInfo | null > {
16- const token = request . headers . get ( 'authorization' ) ?. replace ( / ^ B e a r e r \s + / i, '' )
15+ export async function resolveAuthInfo (
16+ authHeader : string | null ,
17+ ) : Promise < AuthInfo | null > {
18+ const token = authHeader ?. replace ( / ^ B e a r e r \s + / i, '' )
1719 if ( ! token ) return null
1820
1921 const validateUrl = new URL (
Original file line number Diff line number Diff line change 66} from '@modelcontextprotocol/sdk/types.js'
77import { McpAgent } from 'agents/mcp'
88import {
9- getAuthInfo ,
9+ resolveAuthInfo ,
1010 handleOAuthAuthorizationServerRequest ,
1111 handleOAuthProtectedResourceRequest ,
1212 handleUnauthorized ,
@@ -85,7 +85,9 @@ export default {
8585 }
8686
8787 if ( url . pathname === '/mcp' ) {
88- const authInfo = await getAuthInfo ( request )
88+ const authInfo = await resolveAuthInfo (
89+ request . headers . get ( 'authorization' ) ,
90+ )
8991 if ( ! authInfo ) return handleUnauthorized ( request )
9092
9193 const mcp = EpicMeMCP . serve ( '/mcp' , {
You can’t perform that action at this time.
0 commit comments