Skip to content

Commit

Permalink
improve invalid code_challenge error
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-coding committed Aug 4, 2024
1 parent 7fcccca commit 393375a
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ export class OAuthTokenAuthorizationCodeMiddleware extends StateMiddleware<{ cli
this.logger.warn("Code verifier missing");
throw new OAuthHttpException("invalid_request", "Code verifier missing");
}
if (typeof codeVerifier !== "string") {
this.logger.warn("Code verifier is not a string");
throw new OAuthHttpException("invalid_request", "Code verifier has invalid format");
}
const decryptedCodeChallenge = this.encryptionService.decrypt(tokenData.codeChallenge);
const codeChallenge = this.tokenService.calculateCodeChallenge(codeVerifier);
if (decryptedCodeChallenge !== codeChallenge) {
Expand Down

0 comments on commit 393375a

Please sign in to comment.