Created
February 12, 2024 10:15
-
-
Save DavidKlempfner/dd768f32e9a9db9ade54fa7ad04c84c9 to your computer and use it in GitHub Desktop.
ValidateCodeVerifierAgainstCodeChallenge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool ValidateCodeVerifierAgainstCodeChallenge(string codeVerifier, string codeChallenge, string codeChallengeMethod) | |
{ | |
if (codeChallengeMethod == OidcConstants.CodeChallengeMethods.Plain) | |
{ | |
return TimeConstantComparer.IsEqual(codeVerifier.Sha256(), codeChallenge); | |
} | |
var codeVerifierBytes = Encoding.ASCII.GetBytes(codeVerifier); | |
var hashedBytes = codeVerifierBytes.Sha256(); | |
var transformedCodeVerifier = Base64Url.Encode(hashedBytes); | |
return TimeConstantComparer.IsEqual(transformedCodeVerifier.Sha256(), codeChallenge); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment