This commit is contained in:
Olivier Chafik 2025-06-17 11:15:38 +01:00
commit b16a415623
No known key found for this signature in database
2 changed files with 25 additions and 52 deletions

View file

@ -21,6 +21,14 @@ export class DemoInMemoryClientsStore implements OAuthRegisteredClientsStore {
}
}
/**
* 🚨 DEMO ONLY - NOT FOR PRODUCTION
*
* This example demonstrates MCP OAuth flow but lacks some of the features required for production use,
* for example:
* - Persistent token storage
* - Rate limiting
*/
export class DemoInMemoryAuthProvider implements OAuthServerProvider {
clientsStore = new DemoInMemoryClientsStore();
private codes = new Map<string, {
@ -119,12 +127,12 @@ export class DemoInMemoryAuthProvider implements OAuthServerProvider {
}
async exchangeRefreshToken(
client: OAuthClientInformationFull,
_client: OAuthClientInformationFull,
_refreshToken: string,
_scopes?: string[],
resource?: URL
): Promise<OAuthTokens> {
throw new Error('Refresh tokens not implemented for example demo');
throw new Error('Not implemented for example demo');
}
async verifyAccessToken(token: string): Promise<AuthInfo> {

View file

@ -282,12 +282,7 @@ if (useOAuth) {
const mcpServerUrl = new URL(`http://localhost:${MCP_PORT}`);
const authServerUrl = new URL(`http://localhost:${AUTH_PORT}`);
// Configure the demo auth provider to validate resources match this server
const demoProviderConfig = {
serverUrl: mcpServerUrl.href,
validateResourceMatchesServer: false // Set to true to enable strict validation
};
const oauthMetadata: OAuthMetadata = setupAuthServer(authServerUrl, demoProviderConfig);
const oauthMetadata: OAuthMetadata = setupAuthServer(authServerUrl, mcpServerUrl);
const tokenVerifier = {
verifyAccessToken: async (token: string) => {