Skip to content

Commit 236bc5e

Browse files
committedFeb 15, 2025
refactor: remove logging
1 parent 95ea9a7 commit 236bc5e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed
 

Diff for: ‎src/auth/providers/apikey.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { IncomingMessage } from "node:http";
22
import { logger } from "../../core/Logger.js";
33
import { AuthProvider, AuthResult, DEFAULT_AUTH_ERROR } from "../types.js";
44

5+
export const DEFAULT_API_KEY_HEADER_NAME = "X-API-Key"
56
/**
67
* Configuration options for API key authentication
78
*/
@@ -26,7 +27,7 @@ export class APIKeyAuthProvider implements AuthProvider {
2627

2728
constructor(config: APIKeyConfig) {
2829
this.config = {
29-
headerName: "X-API-Key",
30+
headerName: DEFAULT_API_KEY_HEADER_NAME,
3031
...config
3132
};
3233

@@ -78,24 +79,21 @@ export class APIKeyAuthProvider implements AuthProvider {
7879
}
7980

8081
if (!apiKey) {
81-
logger.debug(`API Key header missing. Checked variations: ${headerVariations.join(', ')}`);
82+
logger.debug(`API Key header missing}`);
8283
logger.debug(`Available headers: ${Object.keys(req.headers).join(', ')}`);
8384
return false;
8485
}
8586

8687
logger.debug(`Found API key in header: ${matchedHeader}`);
87-
logger.debug(`Comparing provided key: ${apiKey.substring(0, 3)}... with ${this.config.keys.length} configured keys`);
8888

8989
for (const validKey of this.config.keys) {
90-
logger.debug(`Comparing with key: ${validKey.substring(0, 3)}...`);
9190
if (apiKey === validKey) {
92-
logger.debug(`API Key authentication successful - matched key starting with ${validKey.substring(0, 3)}...`);
91+
logger.debug(`API Key authentication successful`);
9392
return true;
9493
}
9594
}
9695

97-
logger.debug(`Invalid API Key provided: ${apiKey.substring(0, 3)}...`);
98-
logger.debug(`Expected one of: ${this.config.keys.map(k => k.substring(0, 3) + '...').join(', ')}`);
96+
logger.debug(`Invalid API Key provided`);
9997
return false;
10098
}
10199

0 commit comments

Comments
 (0)
Please sign in to comment.