Skip to content

Commit bae0426

Browse files
committed
fix dup logging, rm prm
1 parent c1d5281 commit bae0426

File tree

3 files changed

+42
-31
lines changed

3 files changed

+42
-31
lines changed

src/scenarios/client/auth/helpers/createAuthServer.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createRequestLogger } from '../../../request-logger.js';
55
export interface AuthServerOptions {
66
metadataPath?: string;
77
isOpenIdConfiguration?: boolean;
8+
loggingEnabled?: boolean;
89
}
910

1011
export function createAuthServer(
@@ -14,18 +15,21 @@ export function createAuthServer(
1415
): express.Application {
1516
const {
1617
metadataPath = '/.well-known/oauth-authorization-server',
17-
isOpenIdConfiguration = false
18+
isOpenIdConfiguration = false,
19+
loggingEnabled = true
1820
} = options;
1921
const app = express();
2022
app.use(express.json());
2123
app.use(express.urlencoded({ extended: true }));
2224

23-
app.use(
24-
createRequestLogger(checks, {
25-
incomingId: 'incoming-auth-request',
26-
outgoingId: 'outgoing-auth-response'
27-
})
28-
);
25+
if (loggingEnabled) {
26+
app.use(
27+
createRequestLogger(checks, {
28+
incomingId: 'incoming-auth-request',
29+
outgoingId: 'outgoing-auth-response'
30+
})
31+
);
32+
}
2933

3034
app.get(metadataPath, (req: Request, res: Response) => {
3135
checks.push({

src/scenarios/client/auth/helpers/createServer.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { createRequestLogger } from '../../../request-logger.js';
88
import { MockTokenVerifier } from './mockTokenVerifier.js';
99

1010
export interface ServerOptions {
11-
prmPath?: string;
11+
prmPath?: string | null;
1212
}
1313

1414
export function createServer(
@@ -47,30 +47,32 @@ export function createServer(
4747
})
4848
);
4949

50-
app.get(prmPath, (req: Request, res: Response) => {
51-
checks.push({
52-
id: 'prm-pathbased-requested',
53-
name: 'PRMPathBasedRequested',
54-
description: 'Client requested PRM metadata at path-based location',
55-
status: 'SUCCESS',
56-
timestamp: new Date().toISOString(),
57-
specReferences: [
58-
{
59-
id: 'RFC-9728-3',
60-
url: 'https://tools.ietf.org/html/rfc9728#section-3'
50+
if (prmPath !== null) {
51+
app.get(prmPath, (req: Request, res: Response) => {
52+
checks.push({
53+
id: 'prm-pathbased-requested',
54+
name: 'PRMPathBasedRequested',
55+
description: 'Client requested PRM metadata at path-based location',
56+
status: 'SUCCESS',
57+
timestamp: new Date().toISOString(),
58+
specReferences: [
59+
{
60+
id: 'RFC-9728-3',
61+
url: 'https://tools.ietf.org/html/rfc9728#section-3'
62+
}
63+
],
64+
details: {
65+
url: req.url,
66+
path: req.path
6167
}
62-
],
63-
details: {
64-
url: req.url,
65-
path: req.path
66-
}
67-
});
68+
});
6869

69-
res.json({
70-
resource: getBaseUrl(),
71-
authorization_servers: [getAuthServerUrl()]
70+
res.json({
71+
resource: getBaseUrl(),
72+
authorization_servers: [getAuthServerUrl()]
73+
});
7274
});
73-
});
75+
}
7476

7577
app.post('/mcp', async (req: Request, res: Response, next: NextFunction) => {
7678
// Apply bearer token auth per-request in order to delay setting PRM URL

src/scenarios/client/auth/march-spec-backcompat.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@ export class AuthMarchSpecBackcompatScenario implements Scenario {
1717

1818
// Legacy server, so we create the auth server endpoints on the
1919
// same URL as the main server (rather than separating AS / RS).
20-
const authApp = createAuthServer(this.checks, this.server.getUrl);
20+
const authApp = createAuthServer(this.checks, this.server.getUrl, {
21+
// Disable logging since the main server will already have logging enabled
22+
loggingEnabled: false
23+
});
2124
const app = createServer(
2225
this.checks,
2326
this.server.getUrl,
24-
this.server.getUrl
27+
this.server.getUrl,
28+
// Explicitly set to null to indicate no PRM available
29+
{ prmPath: null }
2530
);
2631
app.use(authApp);
2732

0 commit comments

Comments
 (0)