Skip to content

Commit 28e4547

Browse files
committed
mostly working
1 parent 22fe82c commit 28e4547

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

auth-compat/src/server/validation/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export class ValidationServer {
2323
port: config.port || 0, // 0 means random port
2424
authRequired: config.authRequired || false,
2525
metadataLocation: config.metadataLocation || '/.well-known/oauth-protected-resource',
26-
authServerMetadataLocation: config.authServerMetadataLocation || '/.well-known/oauth-authorization-server'
26+
authServerMetadataLocation: config.authServerMetadataLocation || '/.well-known/oauth-authorization-server',
27+
includeWwwAuthenticate: config.includeWwwAuthenticate !== false // Default true
2728
};
2829

2930
// Start auth server if auth is required
@@ -121,7 +122,9 @@ export class ValidationServer {
121122
// We'll set the full URL dynamically in the middleware
122123
bearerMiddleware = async (req: Request, res: Response, next: any) => {
123124
const serverPort = this.getPort();
124-
const resourceMetadataUrl = `http://localhost:${serverPort}${this.config.metadataLocation}`;
125+
const resourceMetadataUrl = this.config.includeWwwAuthenticate
126+
? `http://localhost:${serverPort}${this.config.metadataLocation}`
127+
: undefined;
125128
const middleware = requireBearerAuth({
126129
verifier: tokenVerifier,
127130
requiredScopes: [],

auth-compat/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ export interface ValidationServerConfig {
4545
authRequired?: boolean;
4646
metadataLocation?: string; // Location for protected resource metadata
4747
authServerMetadataLocation?: string; // Location for auth server metadata (passed to mock auth server)
48+
includeWwwAuthenticate?: boolean; // Whether to include resource_metadata in WWW-Authenticate header
4849
}

0 commit comments

Comments
 (0)