@1mcp/agent 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -37
- package/build/auth/sdkOAuthClientProvider.d.ts +93 -0
- package/build/auth/sdkOAuthClientProvider.d.ts.map +1 -0
- package/build/auth/sdkOAuthClientProvider.js +204 -0
- package/build/auth/sdkOAuthClientProvider.js.map +1 -0
- package/build/auth/sdkOAuthServerProvider.d.ts +64 -0
- package/build/auth/sdkOAuthServerProvider.d.ts.map +1 -0
- package/build/auth/sdkOAuthServerProvider.js +359 -0
- package/build/auth/sdkOAuthServerProvider.js.map +1 -0
- package/build/auth/sessionTypes.d.ts +38 -0
- package/build/auth/sessionTypes.d.ts.map +1 -0
- package/build/auth/sessionTypes.js +3 -0
- package/build/auth/sessionTypes.js.map +1 -0
- package/build/auth/storage/authCodeRepository.d.ts +25 -0
- package/build/auth/storage/authCodeRepository.d.ts.map +1 -0
- package/build/auth/storage/authCodeRepository.js +50 -0
- package/build/auth/storage/authCodeRepository.js.map +1 -0
- package/build/auth/storage/authRequestRepository.d.ts +25 -0
- package/build/auth/storage/authRequestRepository.d.ts.map +1 -0
- package/build/auth/storage/authRequestRepository.js +51 -0
- package/build/auth/storage/authRequestRepository.js.map +1 -0
- package/build/auth/storage/clientDataRepository.d.ts +25 -0
- package/build/auth/storage/clientDataRepository.d.ts.map +1 -0
- package/build/auth/storage/clientDataRepository.js +45 -0
- package/build/auth/storage/clientDataRepository.js.map +1 -0
- package/build/auth/storage/clientSessionRepository.d.ts +77 -0
- package/build/auth/storage/clientSessionRepository.d.ts.map +1 -0
- package/build/auth/storage/clientSessionRepository.js +120 -0
- package/build/auth/storage/clientSessionRepository.js.map +1 -0
- package/build/auth/storage/fileStorageService.d.ts +68 -0
- package/build/auth/storage/fileStorageService.d.ts.map +1 -0
- package/build/auth/storage/fileStorageService.js +262 -0
- package/build/auth/storage/fileStorageService.js.map +1 -0
- package/build/auth/storage/oauthStorageService.d.ts +57 -0
- package/build/auth/storage/oauthStorageService.d.ts.map +1 -0
- package/build/auth/storage/oauthStorageService.js +131 -0
- package/build/auth/storage/oauthStorageService.js.map +1 -0
- package/build/auth/storage/sessionRepository.d.ts +29 -0
- package/build/auth/storage/sessionRepository.d.ts.map +1 -0
- package/build/auth/storage/sessionRepository.js +64 -0
- package/build/auth/storage/sessionRepository.js.map +1 -0
- package/build/capabilities/capabilityManager.d.ts +2 -2
- package/build/capabilities/capabilityManager.d.ts.map +1 -1
- package/build/capabilities/capabilityManager.js +1 -1
- package/build/capabilities/capabilityManager.js.map +1 -1
- package/build/config/{configManager.d.ts → mcpConfigManager.d.ts} +11 -6
- package/build/config/mcpConfigManager.d.ts.map +1 -0
- package/build/config/{configManager.js → mcpConfigManager.js} +26 -8
- package/build/config/mcpConfigManager.js.map +1 -0
- package/build/constants.d.ts +51 -14
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +61 -17
- package/build/constants.js.map +1 -1
- package/build/core/client/clientManager.d.ts +14 -6
- package/build/core/client/clientManager.d.ts.map +1 -1
- package/build/core/client/clientManager.js +90 -28
- package/build/core/client/clientManager.js.map +1 -1
- package/build/core/server/{serverConfig.d.ts → agentConfig.d.ts} +50 -15
- package/build/core/server/agentConfig.d.ts.map +1 -0
- package/build/core/server/agentConfig.js +166 -0
- package/build/core/server/agentConfig.js.map +1 -0
- package/build/core/server/serverManager.d.ts +12 -5
- package/build/core/server/serverManager.d.ts.map +1 -1
- package/build/core/server/serverManager.js +12 -2
- package/build/core/server/serverManager.js.map +1 -1
- package/build/core/types/client.d.ts +22 -9
- package/build/core/types/client.d.ts.map +1 -1
- package/build/core/types/client.js +2 -0
- package/build/core/types/client.js.map +1 -1
- package/build/core/types/server.d.ts +3 -3
- package/build/core/types/server.d.ts.map +1 -1
- package/build/core/types/transport.d.ts +58 -0
- package/build/core/types/transport.d.ts.map +1 -1
- package/build/core/types/transport.js +10 -0
- package/build/core/types/transport.js.map +1 -1
- package/build/handlers/notificationHandlers.d.ts +3 -3
- package/build/handlers/notificationHandlers.d.ts.map +1 -1
- package/build/handlers/notificationHandlers.js +2 -2
- package/build/handlers/notificationHandlers.js.map +1 -1
- package/build/handlers/requestHandlers.d.ts +2 -2
- package/build/handlers/requestHandlers.d.ts.map +1 -1
- package/build/handlers/requestHandlers.js +4 -3
- package/build/handlers/requestHandlers.js.map +1 -1
- package/build/index.js +47 -7
- package/build/index.js.map +1 -1
- package/build/{transport/http/middleware/loggingMiddleware.d.ts → logger/mcpLoggingEnhancer.d.ts} +1 -1
- package/build/logger/mcpLoggingEnhancer.d.ts.map +1 -0
- package/build/{transport/http/middleware/loggingMiddleware.js → logger/mcpLoggingEnhancer.js} +2 -2
- package/build/logger/mcpLoggingEnhancer.js.map +1 -0
- package/build/server.js +4 -4
- package/build/server.js.map +1 -1
- package/build/services/configReloadService.d.ts +2 -2
- package/build/services/configReloadService.d.ts.map +1 -1
- package/build/services/configReloadService.js +4 -4
- package/build/services/configReloadService.js.map +1 -1
- package/build/transport/http/middlewares/errorHandler.d.ts.map +1 -0
- package/build/transport/http/{errorHandler.js → middlewares/errorHandler.js} +1 -1
- package/build/transport/http/middlewares/errorHandler.js.map +1 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts +39 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.d.ts.map +1 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.js +129 -0
- package/build/transport/http/middlewares/scopeAuthMiddleware.js.map +1 -0
- package/build/transport/http/middlewares/securityMiddleware.d.ts +30 -0
- package/build/transport/http/middlewares/securityMiddleware.d.ts.map +1 -0
- package/build/transport/http/middlewares/securityMiddleware.js +201 -0
- package/build/transport/http/middlewares/securityMiddleware.js.map +1 -0
- package/build/transport/http/middlewares/tagsExtractor.d.ts.map +1 -0
- package/build/transport/http/middlewares/tagsExtractor.js.map +1 -0
- package/build/transport/http/routes/oauthRoutes.d.ts +5 -11
- package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/oauthRoutes.js +460 -122
- package/build/transport/http/routes/oauthRoutes.js.map +1 -1
- package/build/transport/http/routes/sseRoutes.d.ts +3 -2
- package/build/transport/http/routes/sseRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/sseRoutes.js +10 -7
- package/build/transport/http/routes/sseRoutes.js.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.d.ts +3 -2
- package/build/transport/http/routes/streamableHttpRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/streamableHttpRoutes.js +17 -10
- package/build/transport/http/routes/streamableHttpRoutes.js.map +1 -1
- package/build/transport/http/server.d.ts +3 -2
- package/build/transport/http/server.d.ts.map +1 -1
- package/build/transport/http/server.js +58 -21
- package/build/transport/http/server.js.map +1 -1
- package/build/transport/transportFactory.d.ts +9 -0
- package/build/transport/transportFactory.d.ts.map +1 -0
- package/build/transport/transportFactory.js +148 -0
- package/build/transport/transportFactory.js.map +1 -0
- package/build/utils/clientFiltering.d.ts +4 -4
- package/build/utils/clientFiltering.d.ts.map +1 -1
- package/build/utils/clientFiltering.js +54 -19
- package/build/utils/clientFiltering.js.map +1 -1
- package/build/utils/errorHandling.d.ts +0 -12
- package/build/utils/errorHandling.d.ts.map +1 -1
- package/build/utils/errorHandling.js +1 -42
- package/build/utils/errorHandling.js.map +1 -1
- package/build/utils/pagination.d.ts +2 -2
- package/build/utils/pagination.d.ts.map +1 -1
- package/build/utils/pagination.js +4 -4
- package/build/utils/pagination.js.map +1 -1
- package/build/utils/parsing.d.ts +13 -0
- package/build/utils/parsing.d.ts.map +1 -0
- package/build/utils/parsing.js +32 -0
- package/build/utils/parsing.js.map +1 -0
- package/build/utils/sanitization.d.ts +60 -0
- package/build/utils/sanitization.d.ts.map +1 -0
- package/build/utils/sanitization.js +149 -0
- package/build/utils/sanitization.js.map +1 -0
- package/build/utils/scopeValidation.d.ts +102 -0
- package/build/utils/scopeValidation.d.ts.map +1 -0
- package/build/utils/scopeValidation.js +244 -0
- package/build/utils/scopeValidation.js.map +1 -0
- package/package.json +20 -11
- package/build/auth/authManager.d.ts +0 -109
- package/build/auth/authManager.d.ts.map +0 -1
- package/build/auth/authManager.js +0 -173
- package/build/auth/authManager.js.map +0 -1
- package/build/auth/authMiddleware.d.ts +0 -16
- package/build/auth/authMiddleware.d.ts.map +0 -1
- package/build/auth/authMiddleware.js +0 -45
- package/build/auth/authMiddleware.js.map +0 -1
- package/build/auth/sessionManager.d.ts +0 -197
- package/build/auth/sessionManager.d.ts.map +0 -1
- package/build/auth/sessionManager.js +0 -408
- package/build/auth/sessionManager.js.map +0 -1
- package/build/config/configManager.d.ts.map +0 -1
- package/build/config/configManager.js.map +0 -1
- package/build/core/server/serverConfig.d.ts.map +0 -1
- package/build/core/server/serverConfig.js +0 -117
- package/build/core/server/serverConfig.js.map +0 -1
- package/build/transport/config.d.ts +0 -7
- package/build/transport/config.d.ts.map +0 -1
- package/build/transport/config.js +0 -90
- package/build/transport/config.js.map +0 -1
- package/build/transport/http/errorHandler.d.ts.map +0 -1
- package/build/transport/http/errorHandler.js.map +0 -1
- package/build/transport/http/middleware/loggingMiddleware.d.ts.map +0 -1
- package/build/transport/http/middleware/loggingMiddleware.js.map +0 -1
- package/build/utils/tagsExtractor.d.ts.map +0 -1
- package/build/utils/tagsExtractor.js.map +0 -1
- /package/build/transport/http/{errorHandler.d.ts → middlewares/errorHandler.d.ts} +0 -0
- /package/build/{utils → transport/http/middlewares}/tagsExtractor.d.ts +0 -0
- /package/build/{utils → transport/http/middlewares}/tagsExtractor.js +0 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import logger from '../logger/logger.js';
|
|
3
|
+
import { OAuthStorageService } from './storage/oauthStorageService.js';
|
|
4
|
+
import { AgentConfigManager } from '../core/server/agentConfig.js';
|
|
5
|
+
import { AUTH_CONFIG } from '../constants.js';
|
|
6
|
+
import { validateScopesAgainstAvailableTags, tagsToScopes, scopesToTags, auditScopeOperation, } from '../utils/scopeValidation.js';
|
|
7
|
+
import { McpConfigManager } from '../config/mcpConfigManager.js';
|
|
8
|
+
/**
|
|
9
|
+
* File-based OAuth clients store implementation using the new repository architecture
|
|
10
|
+
*/
|
|
11
|
+
class FileBasedClientsStore {
|
|
12
|
+
oauthStorage;
|
|
13
|
+
constructor(oauthStorage) {
|
|
14
|
+
this.oauthStorage = oauthStorage;
|
|
15
|
+
}
|
|
16
|
+
getClientKey(clientId) {
|
|
17
|
+
return `${AUTH_CONFIG.CLIENT.PREFIXES.CLIENT}${clientId}`;
|
|
18
|
+
}
|
|
19
|
+
getClient(clientId) {
|
|
20
|
+
const clientKey = this.getClientKey(clientId);
|
|
21
|
+
const clientData = this.oauthStorage.clientDataRepository.get(clientKey);
|
|
22
|
+
if (!clientData) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return clientData;
|
|
26
|
+
}
|
|
27
|
+
registerClient(client) {
|
|
28
|
+
const clientKey = this.getClientKey(client.client_id);
|
|
29
|
+
// Store client for 30 days (same as original implementation)
|
|
30
|
+
const ttlMs = AUTH_CONFIG.CLIENT.OAUTH.TTL_MS;
|
|
31
|
+
try {
|
|
32
|
+
this.oauthStorage.clientDataRepository.save(clientKey, client, ttlMs);
|
|
33
|
+
logger.info(`Registered OAuth client: ${client.client_id}`);
|
|
34
|
+
return client;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
logger.error(`Failed to register client ${client.client_id}:`, error);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Implementation of SDK's OAuthServerProvider interface using the new repository architecture.
|
|
44
|
+
*
|
|
45
|
+
* This provider implements OAuth 2.1 server functionality using the MCP SDK's interfaces
|
|
46
|
+
* with the new layered storage architecture for better separation of concerns.
|
|
47
|
+
*/
|
|
48
|
+
export class SDKOAuthServerProvider {
|
|
49
|
+
oauthStorage;
|
|
50
|
+
configManager;
|
|
51
|
+
_clientsStore;
|
|
52
|
+
constructor(sessionStoragePath) {
|
|
53
|
+
this.oauthStorage = new OAuthStorageService(sessionStoragePath);
|
|
54
|
+
this.configManager = AgentConfigManager.getInstance();
|
|
55
|
+
this._clientsStore = new FileBasedClientsStore(this.oauthStorage);
|
|
56
|
+
}
|
|
57
|
+
get clientsStore() {
|
|
58
|
+
return this._clientsStore;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handles the authorization request with scope validation and user consent
|
|
62
|
+
*/
|
|
63
|
+
async authorize(client, params, res) {
|
|
64
|
+
logger.debug('Authorizing client', { clientId: client.client_id, params });
|
|
65
|
+
try {
|
|
66
|
+
// Get requested scopes (default to all available tags if none specified)
|
|
67
|
+
const requestedScopes = params.scopes || [];
|
|
68
|
+
const configManager = McpConfigManager.getInstance();
|
|
69
|
+
const availableTags = configManager.getAvailableTags();
|
|
70
|
+
// If no scopes requested, default to all available tags
|
|
71
|
+
const finalScopes = requestedScopes.length > 0 ? requestedScopes : tagsToScopes(availableTags);
|
|
72
|
+
// Validate requested scopes against available tags
|
|
73
|
+
const validation = validateScopesAgainstAvailableTags(finalScopes, availableTags);
|
|
74
|
+
if (!validation.isValid) {
|
|
75
|
+
auditScopeOperation('scope_validation_failed', {
|
|
76
|
+
clientId: client.client_id,
|
|
77
|
+
requestedScopes: finalScopes,
|
|
78
|
+
success: false,
|
|
79
|
+
error: validation.errors.join(', '),
|
|
80
|
+
});
|
|
81
|
+
logger.warn(`Invalid scopes requested by client ${client.client_id}`, {
|
|
82
|
+
requestedScopes: finalScopes,
|
|
83
|
+
errors: validation.errors,
|
|
84
|
+
});
|
|
85
|
+
res.status(400).json({
|
|
86
|
+
error: 'invalid_scope',
|
|
87
|
+
error_description: `Invalid scopes: ${validation.errors.join(', ')}`,
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
// Check if this is a direct authorization (auto-approve) or requires user consent
|
|
92
|
+
const requiresUserConsent = this.requiresUserConsent(client, finalScopes);
|
|
93
|
+
if (requiresUserConsent) {
|
|
94
|
+
// Show consent page
|
|
95
|
+
await this.renderConsentPage(client, params, finalScopes, availableTags, res);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// Auto-approve with validated scopes
|
|
99
|
+
await this.approveAuthorization(client, params, validation.validScopes, res);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
logger.error('Authorization error:', error);
|
|
104
|
+
res.status(500).json({ error: 'server_error', error_description: 'Internal server error' });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Determines if user consent is required for the authorization
|
|
109
|
+
*/
|
|
110
|
+
requiresUserConsent(client, scopes) {
|
|
111
|
+
logger.debug('Requires user consent', { clientId: client.client_id, scopes });
|
|
112
|
+
// For now, always require user consent for security
|
|
113
|
+
// In the future, this could be configurable based on client trust level
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Renders the consent page for scope selection
|
|
118
|
+
*/
|
|
119
|
+
async renderConsentPage(client, params, requestedScopes, availableTags, res) {
|
|
120
|
+
// Create temporary authorization request to store the code challenge securely
|
|
121
|
+
const authRequestId = this.oauthStorage.createAuthorizationRequest(client.client_id, params.redirectUri, params.codeChallenge, params.state, params.resource?.toString(), requestedScopes);
|
|
122
|
+
const scopeTags = scopesToTags(requestedScopes);
|
|
123
|
+
const consentPageHtml = this.generateConsentPageHtml(client, authRequestId, scopeTags, availableTags);
|
|
124
|
+
// Remove any CSP that might interfere with form submission
|
|
125
|
+
res.removeHeader('Content-Security-Policy');
|
|
126
|
+
res.set('Content-Type', 'text/html');
|
|
127
|
+
res.send(consentPageHtml);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Approves the authorization and redirects back to client
|
|
131
|
+
*/
|
|
132
|
+
async approveAuthorization(client, params, grantedScopes, res) {
|
|
133
|
+
logger.debug('Approving authorization', { clientId: client.client_id, params, grantedScopes });
|
|
134
|
+
// Create authorization code with granted scopes
|
|
135
|
+
const ttlMs = this.configManager.getOAuthCodeTtlMs();
|
|
136
|
+
const code = this.oauthStorage.authCodeRepository.create(client.client_id, params.redirectUri, params.resource?.toString() || '', grantedScopes, ttlMs, params.codeChallenge);
|
|
137
|
+
// Build redirect URL
|
|
138
|
+
const redirectUrl = new URL(params.redirectUri);
|
|
139
|
+
redirectUrl.searchParams.set('code', code);
|
|
140
|
+
if (params.state) {
|
|
141
|
+
redirectUrl.searchParams.set('state', params.state);
|
|
142
|
+
}
|
|
143
|
+
auditScopeOperation('authorization_granted', {
|
|
144
|
+
clientId: client.client_id,
|
|
145
|
+
requestedScopes: params.scopes || [],
|
|
146
|
+
grantedScopes,
|
|
147
|
+
success: true,
|
|
148
|
+
});
|
|
149
|
+
logger.info(`OAuth authorization granted for client ${client.client_id}`, {
|
|
150
|
+
clientId: client.client_id,
|
|
151
|
+
redirectUri: params.redirectUri,
|
|
152
|
+
grantedScopes,
|
|
153
|
+
});
|
|
154
|
+
res.redirect(redirectUrl.toString());
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Generates the HTML for the consent page
|
|
158
|
+
*/
|
|
159
|
+
generateConsentPageHtml(client, authRequestId, requestedTags, availableTags) {
|
|
160
|
+
const clientName = client.client_name || client.client_id;
|
|
161
|
+
return `
|
|
162
|
+
<!DOCTYPE html>
|
|
163
|
+
<html>
|
|
164
|
+
<head>
|
|
165
|
+
<title>Authorize ${clientName}</title>
|
|
166
|
+
<meta charset="utf-8">
|
|
167
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
168
|
+
<style>
|
|
169
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 0; padding: 20px; background: #f5f5f5; }
|
|
170
|
+
.container { max-width: 500px; margin: 0 auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
|
171
|
+
h1 { color: #333; margin-bottom: 20px; }
|
|
172
|
+
.app-info { background: #f8f9fa; padding: 15px; border-radius: 6px; margin-bottom: 20px; }
|
|
173
|
+
.scopes-section { margin-bottom: 25px; }
|
|
174
|
+
.scope-item { display: flex; align-items: center; margin-bottom: 10px; }
|
|
175
|
+
.scope-item input { margin-right: 10px; }
|
|
176
|
+
.scope-item label { flex: 1; }
|
|
177
|
+
.tag-description { font-size: 0.9em; color: #666; margin-left: 25px; }
|
|
178
|
+
.buttons { display: flex; gap: 10px; justify-content: flex-end; }
|
|
179
|
+
.btn { padding: 10px 20px; border-radius: 4px; font-size: 14px; cursor: pointer; }
|
|
180
|
+
.btn-primary { background: #007bff; color: white; border: none; }
|
|
181
|
+
.btn-secondary { background: #6c757d; color: white; border: none; }
|
|
182
|
+
.btn:hover { opacity: 0.9; }
|
|
183
|
+
.security-notice { background: #fff3cd; border: 1px solid #ffeaa7; padding: 15px; border-radius: 4px; margin-bottom: 20px; }
|
|
184
|
+
</style>
|
|
185
|
+
</head>
|
|
186
|
+
<body>
|
|
187
|
+
<div class="container">
|
|
188
|
+
<h1>Authorize Application</h1>
|
|
189
|
+
|
|
190
|
+
<div class="app-info">
|
|
191
|
+
<strong>${clientName}</strong> is requesting access to your MCP servers.
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<div class="security-notice">
|
|
195
|
+
<strong>Security Notice:</strong> Only grant access to server groups that this application needs.
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
<form method="POST" action="/oauth/consent">
|
|
199
|
+
<input type="hidden" name="auth_request_id" value="${authRequestId}">
|
|
200
|
+
|
|
201
|
+
<div class="scopes-section">
|
|
202
|
+
<h3>Server Access Permissions</h3>
|
|
203
|
+
<p>Select which server groups this application can access:</p>
|
|
204
|
+
|
|
205
|
+
${availableTags
|
|
206
|
+
.map((tag) => `
|
|
207
|
+
<div class="scope-item">
|
|
208
|
+
<input type="checkbox"
|
|
209
|
+
id="scope_${tag}"
|
|
210
|
+
name="scopes"
|
|
211
|
+
value="tag:${tag}"
|
|
212
|
+
${requestedTags.includes(tag) ? 'checked' : ''}>
|
|
213
|
+
<label for="scope_${tag}">
|
|
214
|
+
<strong>${tag}</strong> servers
|
|
215
|
+
</label>
|
|
216
|
+
</div>
|
|
217
|
+
<div class="tag-description">
|
|
218
|
+
Access servers tagged with "${tag}"
|
|
219
|
+
</div>
|
|
220
|
+
`)
|
|
221
|
+
.join('')}
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<div class="buttons">
|
|
225
|
+
<button type="submit" name="action" value="deny" class="btn btn-secondary">Deny</button>
|
|
226
|
+
<button type="submit" name="action" value="approve" class="btn btn-primary">Approve</button>
|
|
227
|
+
</div>
|
|
228
|
+
</form>
|
|
229
|
+
</div>
|
|
230
|
+
</body>
|
|
231
|
+
</html>
|
|
232
|
+
`;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Retrieves the PKCE challenge for an authorization code
|
|
236
|
+
*/
|
|
237
|
+
async challengeForAuthorizationCode(client, authorizationCode) {
|
|
238
|
+
logger.debug('Challenge for authorization code', { clientId: client.client_id, authorizationCode });
|
|
239
|
+
const codeData = this.oauthStorage.authCodeRepository.get(authorizationCode);
|
|
240
|
+
if (!codeData || codeData.clientId !== client.client_id) {
|
|
241
|
+
throw new Error('Invalid authorization code');
|
|
242
|
+
}
|
|
243
|
+
return codeData.codeChallenge || '';
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Exchanges authorization code for access token
|
|
247
|
+
*/
|
|
248
|
+
async exchangeAuthorizationCode(client, authorizationCode,
|
|
249
|
+
// Note: code verifier is checked in SDK's token.ts by default
|
|
250
|
+
// it's unused here for that reason.
|
|
251
|
+
_codeVerifier, redirectUri, resource) {
|
|
252
|
+
logger.debug('Exchanging authorization code', {
|
|
253
|
+
clientId: client.client_id,
|
|
254
|
+
authorizationCode,
|
|
255
|
+
redirectUri,
|
|
256
|
+
resource,
|
|
257
|
+
});
|
|
258
|
+
const codeData = this.oauthStorage.authCodeRepository.get(authorizationCode);
|
|
259
|
+
if (!codeData) {
|
|
260
|
+
throw new Error('Invalid or expired authorization code');
|
|
261
|
+
}
|
|
262
|
+
// Validate client ID
|
|
263
|
+
if (codeData.clientId !== client.client_id) {
|
|
264
|
+
throw new Error('Client ID mismatch');
|
|
265
|
+
}
|
|
266
|
+
// Validate redirect URI if provided
|
|
267
|
+
if (redirectUri && codeData.redirectUri !== redirectUri) {
|
|
268
|
+
throw new Error('Redirect URI mismatch');
|
|
269
|
+
}
|
|
270
|
+
// Validate resource if provided
|
|
271
|
+
if (resource && codeData.resource && codeData.resource !== resource.toString()) {
|
|
272
|
+
throw new Error('Resource mismatch');
|
|
273
|
+
}
|
|
274
|
+
// Delete the authorization code (one-time use)
|
|
275
|
+
this.oauthStorage.authCodeRepository.delete(authorizationCode);
|
|
276
|
+
// Create access token
|
|
277
|
+
const tokenId = randomUUID();
|
|
278
|
+
const accessToken = AUTH_CONFIG.SERVER.TOKEN.ID_PREFIX + tokenId;
|
|
279
|
+
const ttlMs = this.configManager.getOAuthTokenTtlMs();
|
|
280
|
+
// Store session for token validation
|
|
281
|
+
this.oauthStorage.sessionRepository.createWithId(tokenId, client.client_id, codeData.resource || '', codeData.scopes, ttlMs);
|
|
282
|
+
const tokens = {
|
|
283
|
+
access_token: accessToken,
|
|
284
|
+
token_type: 'Bearer',
|
|
285
|
+
expires_in: Math.floor(ttlMs / 1000),
|
|
286
|
+
scope: codeData.scopes ? codeData.scopes.join(' ') : '',
|
|
287
|
+
};
|
|
288
|
+
logger.info(`Exchanged authorization code for access token`, {
|
|
289
|
+
clientId: client.client_id,
|
|
290
|
+
tokenId: tokenId.substring(0, 8) + '...',
|
|
291
|
+
expiresIn: tokens.expires_in,
|
|
292
|
+
});
|
|
293
|
+
return tokens;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Exchanges refresh token for new access token (not implemented)
|
|
297
|
+
*/
|
|
298
|
+
async exchangeRefreshToken(_client, _refreshToken, _scopes, _resource) {
|
|
299
|
+
throw new Error('Refresh tokens not supported');
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Verifies access token and returns auth info with granted scopes
|
|
303
|
+
*/
|
|
304
|
+
async verifyAccessToken(token) {
|
|
305
|
+
logger.debug('Verifying access token', { token });
|
|
306
|
+
if (!this.configManager.isAuthEnabled()) {
|
|
307
|
+
// Auth disabled, return minimal auth info with all available tags as scopes
|
|
308
|
+
const configManager = McpConfigManager.getInstance();
|
|
309
|
+
const availableTags = configManager.getAvailableTags();
|
|
310
|
+
return {
|
|
311
|
+
token,
|
|
312
|
+
clientId: 'anonymous',
|
|
313
|
+
scopes: tagsToScopes(availableTags),
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
// Strip prefix if present
|
|
317
|
+
const tokenId = token.startsWith(AUTH_CONFIG.SERVER.TOKEN.ID_PREFIX)
|
|
318
|
+
? token.slice(AUTH_CONFIG.SERVER.TOKEN.ID_PREFIX.length)
|
|
319
|
+
: token;
|
|
320
|
+
// Get session data
|
|
321
|
+
const sessionId = AUTH_CONFIG.SERVER.SESSION.ID_PREFIX + tokenId;
|
|
322
|
+
const sessionData = this.oauthStorage.sessionRepository.get(sessionId);
|
|
323
|
+
if (!sessionData) {
|
|
324
|
+
throw new Error('Invalid or expired access token');
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
token,
|
|
328
|
+
clientId: sessionData.clientId,
|
|
329
|
+
scopes: sessionData.scopes,
|
|
330
|
+
expiresAt: sessionData.expires,
|
|
331
|
+
resource: sessionData.resource ? new URL(sessionData.resource) : undefined,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Revokes a token
|
|
336
|
+
*/
|
|
337
|
+
async revokeToken(client, request) {
|
|
338
|
+
logger.debug('Revoking token', { clientId: client.client_id, request });
|
|
339
|
+
const token = request.token;
|
|
340
|
+
// Strip prefix if present
|
|
341
|
+
const tokenId = token.startsWith(AUTH_CONFIG.SERVER.TOKEN.ID_PREFIX)
|
|
342
|
+
? token.slice(AUTH_CONFIG.SERVER.TOKEN.ID_PREFIX.length)
|
|
343
|
+
: token;
|
|
344
|
+
const sessionId = AUTH_CONFIG.SERVER.SESSION.ID_PREFIX + tokenId;
|
|
345
|
+
const success = this.oauthStorage.sessionRepository.delete(sessionId);
|
|
346
|
+
if (success) {
|
|
347
|
+
logger.info(`Revoked access token for client ${client.client_id}`, {
|
|
348
|
+
tokenId: tokenId.substring(0, 8) + '...',
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Graceful shutdown
|
|
354
|
+
*/
|
|
355
|
+
shutdown() {
|
|
356
|
+
this.oauthStorage.shutdown();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
//# sourceMappingURL=sdkOAuthServerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkOAuthServerProvider.js","sourceRoot":"","sources":["../../src/auth/sdkOAuthServerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAUzC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,kCAAkC,EAClC,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE;;GAEG;AACH,MAAM,qBAAqB;IACjB,YAAY,CAAsB;IAE1C,YAAY,YAAiC;QAC3C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,YAAY,CAA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CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;SAC3E,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,MAAkC,EAAE,OAAoC;QACxF,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;QAExE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE5B,0BAA0B;QAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;YAClE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC;YACxD,CAAC,CAAC,KAAK,CAAC;QAEV,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC;QACjE,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEtE,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,IAAI,CAAC,mCAAmC,MAAM,CAAC,SAAS,EAAE,EAAE;gBACjE,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK;aACzC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { OAuthClientInformationFull } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base interface for all data that can expire
|
|
4
|
+
*/
|
|
5
|
+
export interface ExpirableData {
|
|
6
|
+
expires: number;
|
|
7
|
+
createdAt: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SessionData extends ExpirableData {
|
|
10
|
+
clientId: string;
|
|
11
|
+
resource: string;
|
|
12
|
+
scopes: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface ClientData extends ExpirableData, OAuthClientInformationFull {
|
|
15
|
+
}
|
|
16
|
+
export interface AuthCodeData extends ExpirableData {
|
|
17
|
+
clientId: string;
|
|
18
|
+
redirectUri: string;
|
|
19
|
+
resource: string;
|
|
20
|
+
scopes: string[];
|
|
21
|
+
codeChallenge?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ClientSessionData extends ExpirableData {
|
|
24
|
+
serverName: string;
|
|
25
|
+
clientInfo?: string;
|
|
26
|
+
tokens?: string;
|
|
27
|
+
codeVerifier?: string;
|
|
28
|
+
state?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface AuthRequestData extends ExpirableData {
|
|
31
|
+
clientId: string;
|
|
32
|
+
redirectUri: string;
|
|
33
|
+
codeChallenge?: string;
|
|
34
|
+
state?: string;
|
|
35
|
+
resource?: string;
|
|
36
|
+
scopes?: string[];
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=sessionTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionTypes.d.ts","sourceRoot":"","sources":["../../src/auth/sessionTypes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,UAAW,SAAQ,aAAa,EAAE,0BAA0B;CAAG;AAEhF,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAGD,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionTypes.js","sourceRoot":"","sources":["../../src/auth/sessionTypes.ts"],"names":[],"mappings":"AAAA,8DAA8D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AuthCodeData } from '../sessionTypes.js';
|
|
2
|
+
import { FileStorageService } from './fileStorageService.js';
|
|
3
|
+
/**
|
|
4
|
+
* Repository for authorization code operations
|
|
5
|
+
*
|
|
6
|
+
* Manages OAuth 2.1 authorization codes for token exchange.
|
|
7
|
+
* Authorization codes are short-lived (1 minute) and single-use.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AuthCodeRepository {
|
|
10
|
+
private storage;
|
|
11
|
+
constructor(storage: FileStorageService);
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new authorization code
|
|
14
|
+
*/
|
|
15
|
+
create(clientId: string, redirectUri: string, resource: string, scopes: string[], ttlMs: number, codeChallenge?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves authorization code data by code
|
|
18
|
+
*/
|
|
19
|
+
get(code: string): AuthCodeData | null;
|
|
20
|
+
/**
|
|
21
|
+
* Deletes an authorization code by code
|
|
22
|
+
*/
|
|
23
|
+
delete(code: string): boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=authCodeRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authCodeRepository.d.ts","sourceRoot":"","sources":["../../../src/auth/storage/authCodeRepository.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;GAKG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,kBAAkB;IAE/C;;OAEG;IACH,MAAM,CACJ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM;IAiBT;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAItC;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAO9B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import logger from '../../logger/logger.js';
|
|
3
|
+
import { AUTH_CONFIG } from '../../constants.js';
|
|
4
|
+
/**
|
|
5
|
+
* Repository for authorization code operations
|
|
6
|
+
*
|
|
7
|
+
* Manages OAuth 2.1 authorization codes for token exchange.
|
|
8
|
+
* Authorization codes are short-lived (1 minute) and single-use.
|
|
9
|
+
*/
|
|
10
|
+
export class AuthCodeRepository {
|
|
11
|
+
storage;
|
|
12
|
+
constructor(storage) {
|
|
13
|
+
this.storage = storage;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new authorization code
|
|
17
|
+
*/
|
|
18
|
+
create(clientId, redirectUri, resource, scopes, ttlMs, codeChallenge) {
|
|
19
|
+
const code = AUTH_CONFIG.SERVER.AUTH_CODE.ID_PREFIX + randomUUID();
|
|
20
|
+
const authCodeData = {
|
|
21
|
+
clientId,
|
|
22
|
+
redirectUri,
|
|
23
|
+
resource,
|
|
24
|
+
scopes,
|
|
25
|
+
codeChallenge,
|
|
26
|
+
expires: Date.now() + ttlMs,
|
|
27
|
+
createdAt: Date.now(),
|
|
28
|
+
};
|
|
29
|
+
this.storage.writeData(AUTH_CONFIG.SERVER.AUTH_CODE.FILE_PREFIX, code, authCodeData);
|
|
30
|
+
logger.info(`Created auth code: ${code} for client: ${clientId}`);
|
|
31
|
+
return code;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves authorization code data by code
|
|
35
|
+
*/
|
|
36
|
+
get(code) {
|
|
37
|
+
return this.storage.readData(AUTH_CONFIG.SERVER.AUTH_CODE.FILE_PREFIX, code);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Deletes an authorization code by code
|
|
41
|
+
*/
|
|
42
|
+
delete(code) {
|
|
43
|
+
const result = this.storage.deleteData(AUTH_CONFIG.SERVER.AUTH_CODE.FILE_PREFIX, code);
|
|
44
|
+
if (result) {
|
|
45
|
+
logger.info(`Deleted auth code: ${code}`);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=authCodeRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authCodeRepository.js","sourceRoot":"","sources":["../../../src/auth/storage/authCodeRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACz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;QAC5C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AuthRequestData } from '../sessionTypes.js';
|
|
2
|
+
import { FileStorageService } from './fileStorageService.js';
|
|
3
|
+
/**
|
|
4
|
+
* Repository for authorization request operations
|
|
5
|
+
*
|
|
6
|
+
* Manages temporary authorization requests used in the consent flow.
|
|
7
|
+
* These store OAuth parameters securely server-side while user reviews consent.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AuthRequestRepository {
|
|
10
|
+
private storage;
|
|
11
|
+
constructor(storage: FileStorageService);
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new authorization request
|
|
14
|
+
*/
|
|
15
|
+
create(clientId: string, redirectUri: string, codeChallenge?: string, state?: string, resource?: string, scopes?: string[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves authorization request data by ID
|
|
18
|
+
*/
|
|
19
|
+
get(authRequestId: string): AuthRequestData | null;
|
|
20
|
+
/**
|
|
21
|
+
* Deletes an authorization request by ID
|
|
22
|
+
*/
|
|
23
|
+
delete(authRequestId: string): boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=authRequestRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authRequestRepository.d.ts","sourceRoot":"","sources":["../../../src/auth/storage/authRequestRepository.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;GAKG;AACH,qBAAa,qBAAqB;IACpB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,kBAAkB;IAE/C;;OAEG;IACH,MAAM,CACJ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,aAAa,CAAC,EAAE,MAAM,EACtB,KAAK,CAAC,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,EAAE,GAChB,MAAM;IAkBT;;OAEG;IACH,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;IAIlD;;OAEG;IACH,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;CAOvC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import logger from '../../logger/logger.js';
|
|
3
|
+
import { AUTH_CONFIG } from '../../constants.js';
|
|
4
|
+
/**
|
|
5
|
+
* Repository for authorization request operations
|
|
6
|
+
*
|
|
7
|
+
* Manages temporary authorization requests used in the consent flow.
|
|
8
|
+
* These store OAuth parameters securely server-side while user reviews consent.
|
|
9
|
+
*/
|
|
10
|
+
export class AuthRequestRepository {
|
|
11
|
+
storage;
|
|
12
|
+
constructor(storage) {
|
|
13
|
+
this.storage = storage;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new authorization request
|
|
17
|
+
*/
|
|
18
|
+
create(clientId, redirectUri, codeChallenge, state, resource, scopes) {
|
|
19
|
+
const authRequestId = AUTH_CONFIG.SERVER.AUTH_REQUEST.ID_PREFIX + randomUUID();
|
|
20
|
+
const authRequestData = {
|
|
21
|
+
clientId,
|
|
22
|
+
redirectUri,
|
|
23
|
+
codeChallenge,
|
|
24
|
+
state,
|
|
25
|
+
resource,
|
|
26
|
+
scopes,
|
|
27
|
+
expires: Date.now() + AUTH_CONFIG.SERVER.AUTH_REQUEST.TTL_MS,
|
|
28
|
+
createdAt: Date.now(),
|
|
29
|
+
};
|
|
30
|
+
this.storage.writeData(AUTH_CONFIG.SERVER.AUTH_REQUEST.FILE_PREFIX, authRequestId, authRequestData);
|
|
31
|
+
logger.info(`Created auth request: ${authRequestId} for client: ${clientId}`);
|
|
32
|
+
return authRequestId;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves authorization request data by ID
|
|
36
|
+
*/
|
|
37
|
+
get(authRequestId) {
|
|
38
|
+
return this.storage.readData(AUTH_CONFIG.SERVER.AUTH_REQUEST.FILE_PREFIX, authRequestId);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Deletes an authorization request by ID
|
|
42
|
+
*/
|
|
43
|
+
delete(authRequestId) {
|
|
44
|
+
const result = this.storage.deleteData(AUTH_CONFIG.SERVER.AUTH_REQUEST.FILE_PREFIX, authRequestId);
|
|
45
|
+
if (result) {
|
|
46
|
+
logger.info(`Deleted auth request: ${authRequestId}`);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=authRequestRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authRequestRepository.js","sourceRoot":"","sources":["../../../src/auth/storage/authRequestRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IACZ;IAApB,YAAoB,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;IAAG,CAAC;IAEnD;;OAEG;IACH,MAAM,CACJ,QAAgB,EAChB,WAAmB,EACnB,aAAsB,EACtB,KAAc,EACd,QAAiB,EACjB,MAAiB;QAEjB,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,GAAG,UAAU,EAAE,CAAC;QAC/E,MAAM,eAAe,GAAoB;YACvC,QAAQ;YACR,WAAW;YACX,aAAa;YACb,KAAK;YACL,QAAQ;YACR,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM;YAC5D,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;QACpG,MAAM,CAAC,IAAI,CAAC,yBAAyB,aAAa,gBAAgB,QAAQ,EAAE,CAAC,CAAC;QAC9E,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,aAAqB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAkB,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC5G,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAqB;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QACnG,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,yBAAyB,aAAa,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FileStorageService } from './fileStorageService.js';
|
|
2
|
+
import { OAuthClientInformationFull } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
3
|
+
/**
|
|
4
|
+
* Repository for OAuth client data operations
|
|
5
|
+
*
|
|
6
|
+
* Manages registered OAuth client information with automatic expiration.
|
|
7
|
+
* Client data is stored for a configurable period (default 30 days).
|
|
8
|
+
*/
|
|
9
|
+
export declare class ClientDataRepository {
|
|
10
|
+
private storage;
|
|
11
|
+
constructor(storage: FileStorageService);
|
|
12
|
+
/**
|
|
13
|
+
* Saves OAuth client data
|
|
14
|
+
*/
|
|
15
|
+
save(clientId: string, data: OAuthClientInformationFull, ttlMs: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves OAuth client data by client ID
|
|
18
|
+
*/
|
|
19
|
+
get(clientId: string): OAuthClientInformationFull | null;
|
|
20
|
+
/**
|
|
21
|
+
* Deletes OAuth client data by client ID
|
|
22
|
+
*/
|
|
23
|
+
delete(clientId: string): boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=clientDataRepository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientDataRepository.d.ts","sourceRoot":"","sources":["../../../src/auth/storage/clientDataRepository.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAEtF;;;;;GAKG;AACH,qBAAa,oBAAoB;IACnB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,kBAAkB;IAE/C;;OAEG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAY/E;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,0BAA0B,GAAG,IAAI;IAKxD;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAOlC"}
|