Skip to content

Commit 14459ac

Browse files
nickytonlineclaude
andcommitted
security(oauth): enable client auth and remove token logging
- Enable client authentication for authorization code flow (OAuth 2.1 compliance) - Remove sensitive token fragments from log messages - Replace token substrings with token length for debugging - Improves security by preventing token exposure in logs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 0b808c9 commit 14459ac

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/auth/discovery.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ export function createAuthorizeHandler(oauthServer: OAuth2Server) {
133133

134134
logger.info("Authorization code granted", {
135135
clientId: authorizationCode.client.id,
136-
userId: user.id,
137-
code: authorizationCode.authorizationCode.substring(0, 8) + "..."
136+
userId: user.id
138137
});
139138

140139
// Redirect back to client with authorization code

src/auth/oauth-provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ export class OAuthProvider {
126126

127127
const codeData = this.#authorizationCodes.get(code);
128128
if (!codeData) {
129-
logger.warn("Invalid authorization code", { code: code.substring(0, 8) + "..." });
129+
logger.warn("Invalid authorization code", { codeLength: code.length });
130130
return null;
131131
}
132132

133133
// Check expiration
134134
if (codeData.expiresAt < new Date()) {
135135
this.#authorizationCodes.delete(code);
136-
logger.warn("Expired authorization code", { code: code.substring(0, 8) + "..." });
136+
logger.warn("Expired authorization code", { codeLength: code.length });
137137
return null;
138138
}
139139

@@ -150,7 +150,7 @@ export class OAuthProvider {
150150

151151
// PKCE verification
152152
if (!this.verifyPKCE(codeVerifier, codeData.codeChallenge)) {
153-
logger.warn("PKCE verification failed", { code: code.substring(0, 8) + "..." });
153+
logger.warn("PKCE verification failed", { codeLength: code.length });
154154
return null;
155155
}
156156

src/auth/oauth-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class ManagedOAuthServer {
156156
},
157157

158158
// OAuth 2.1 configuration
159-
requireClientAuthentication: { authorization_code: false },
159+
requireClientAuthentication: { authorization_code: true },
160160
allowBearerTokensInQueryString: false,
161161
accessTokenLifetime: 3600, // 1 hour
162162
authorizationCodeLifetime: 600, // 10 minutes

0 commit comments

Comments
 (0)