Skip to content

Commit 5e0302f

Browse files
Allow HTTP issuer URLs when MCP_DEV_MODE is enabled (#1189)
Co-authored-by: Claude <[email protected]>
1 parent b4c6090 commit 5e0302f

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

package-lock.json

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/server/auth/router.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import { metadataHandler } from './handlers/metadata.js';
77
import { OAuthServerProvider } from './provider.js';
88
import { OAuthMetadata, OAuthProtectedResourceMetadata } from '../../shared/auth.js';
99

10+
// Check for dev mode flag that allows HTTP issuer URLs (for development/testing only)
11+
const allowInsecureIssuerUrl =
12+
process.env.MCP_DANGEROUSLY_ALLOW_INSECURE_ISSUER_URL === 'true' || process.env.MCP_DANGEROUSLY_ALLOW_INSECURE_ISSUER_URL === '1';
13+
if (allowInsecureIssuerUrl) {
14+
// eslint-disable-next-line no-console
15+
console.warn('MCP_DANGEROUSLY_ALLOW_INSECURE_ISSUER_URL is enabled - HTTP issuer URLs are allowed. Do not use in production.');
16+
}
17+
1018
export type AuthRouterOptions = {
1119
/**
1220
* A provider implementing the actual authorization logic for this router.
@@ -55,7 +63,7 @@ export type AuthRouterOptions = {
5563

5664
const checkIssuerUrl = (issuer: URL): void => {
5765
// Technically RFC 8414 does not permit a localhost HTTPS exemption, but this will be necessary for ease of testing
58-
if (issuer.protocol !== 'https:' && issuer.hostname !== 'localhost' && issuer.hostname !== '127.0.0.1') {
66+
if (issuer.protocol !== 'https:' && issuer.hostname !== 'localhost' && issuer.hostname !== '127.0.0.1' && !allowInsecureIssuerUrl) {
5967
throw new Error('Issuer URL must be HTTPS');
6068
}
6169
if (issuer.hash) {

0 commit comments

Comments
 (0)