@giantswarm-io/pro 1.8.0 → 1.8.2
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/package.json +1 -1
- package/src/lib/auth/provider.js +11 -4
package/package.json
CHANGED
package/src/lib/auth/provider.js
CHANGED
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
import { randomUUID } from 'crypto';
|
|
41
41
|
import net from 'node:net';
|
|
42
|
+
import { InvalidGrantError, UnsupportedGrantTypeError } from '@modelcontextprotocol/sdk/server/auth/errors.js';
|
|
42
43
|
import { logger } from '../logger.js';
|
|
43
44
|
|
|
44
45
|
// TTL for authorization sessions (10 minutes)
|
|
@@ -376,13 +377,19 @@ export function createGitHubOAuthProvider(config) {
|
|
|
376
377
|
res.redirect(githubUrl.toString());
|
|
377
378
|
},
|
|
378
379
|
|
|
380
|
+
// Errors thrown from the token-grant methods below must be MCP SDK
|
|
381
|
+
// OAuthError subclasses: the SDK's /token handler turns those into the
|
|
382
|
+
// RFC 6749 §5.2 error response (400 + error code) and anything else into
|
|
383
|
+
// an opaque 500 server_error. A bad or expired code is invalid_grant, so a
|
|
384
|
+
// client can tell "start over" apart from "the server is broken".
|
|
385
|
+
|
|
379
386
|
/**
|
|
380
387
|
* Return the PKCE code challenge for a local authorization code.
|
|
381
388
|
*/
|
|
382
389
|
async challengeForAuthorizationCode(_client, authorizationCode) {
|
|
383
390
|
const entry = authCodes.get(authorizationCode);
|
|
384
391
|
if (!entry) {
|
|
385
|
-
throw new
|
|
392
|
+
throw new InvalidGrantError('Authorization code not found or expired');
|
|
386
393
|
}
|
|
387
394
|
return entry.codeChallenge;
|
|
388
395
|
},
|
|
@@ -393,11 +400,11 @@ export function createGitHubOAuthProvider(config) {
|
|
|
393
400
|
async exchangeAuthorizationCode(client, authorizationCode) {
|
|
394
401
|
const entry = authCodes.get(authorizationCode);
|
|
395
402
|
if (!entry) {
|
|
396
|
-
throw new
|
|
403
|
+
throw new InvalidGrantError('Authorization code not found or expired');
|
|
397
404
|
}
|
|
398
405
|
|
|
399
406
|
if (entry.clientId !== client.client_id) {
|
|
400
|
-
throw new
|
|
407
|
+
throw new InvalidGrantError('Authorization code was issued to a different client');
|
|
401
408
|
}
|
|
402
409
|
|
|
403
410
|
// Delete the code (single use)
|
|
@@ -422,7 +429,7 @@ export function createGitHubOAuthProvider(config) {
|
|
|
422
429
|
* so we reject these requests.
|
|
423
430
|
*/
|
|
424
431
|
async exchangeRefreshToken() {
|
|
425
|
-
throw new
|
|
432
|
+
throw new UnsupportedGrantTypeError('Refresh tokens are not supported. Re-authorize to get a new token.');
|
|
426
433
|
},
|
|
427
434
|
|
|
428
435
|
/**
|