Skip to content

Commit fe374d8

Browse files
Address review feedback: rename env var and warn at startup
1 parent df9aac8 commit fe374d8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/server/auth/router.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ 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 allowHttpForDev = process.env.MCP_ALLOW_HTTP_AUTH_FOR_DEV_UNSAFE === 'true' || process.env.MCP_ALLOW_HTTP_AUTH_FOR_DEV_UNSAFE === '1';
12+
if (allowHttpForDev) {
13+
console.warn('MCP_ALLOW_HTTP_AUTH_FOR_DEV_UNSAFE is enabled - HTTP issuer URLs are allowed. Do not use in production.');
14+
}
15+
1016
export type AuthRouterOptions = {
1117
/**
1218
* A provider implementing the actual authorization logic for this router.
@@ -55,9 +61,7 @@ export type AuthRouterOptions = {
5561

5662
const checkIssuerUrl = (issuer: URL): void => {
5763
// Technically RFC 8414 does not permit a localhost HTTPS exemption, but this will be necessary for ease of testing
58-
// Also allow HTTP in development mode for testing with non-localhost URLs (e.g., Docker environments)
59-
const devMode = process.env.MCP_DEV_MODE === 'true' || process.env.MCP_DEV_MODE === '1';
60-
if (issuer.protocol !== 'https:' && issuer.hostname !== 'localhost' && issuer.hostname !== '127.0.0.1' && !devMode) {
64+
if (issuer.protocol !== 'https:' && issuer.hostname !== 'localhost' && issuer.hostname !== '127.0.0.1' && !allowHttpForDev) {
6165
throw new Error('Issuer URL must be HTTPS');
6266
}
6367
if (issuer.hash) {

0 commit comments

Comments
 (0)