Created
August 15, 2019 00:05
-
-
Save rbrayb/66e1652516aca85cad1b8417d0d2d227 to your computer and use it in GitHub Desktop.
Using Proof Key for Code Exchange (PKCE) in ADFS for Windows Server 2019
This file contains 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
using IdentityModel; | |
using System; | |
using System.Security.Cryptography; | |
using System.Text; | |
namespace ADFS_PKCE_Core | |
{ | |
class Program | |
{ | |
// https://www.scottbrady91.com/OpenID-Connect/ASPNET-Core-using-Proof-Key-for-Code-Exchange-PKCE | |
static void Main(string[] args) | |
{ | |
//var codeVerifier = CryptoRandom.CreateUniqueId(32); | |
var codeVerifier = "1qaz2wsx3edc4rfv5tgb6yhn1234567890qwertyuiop"; | |
string codeChallenge; | |
using (var sha256 = SHA256.Create()) | |
{ | |
var challengeBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(codeVerifier)); | |
codeChallenge = Base64Url.Encode(challengeBytes); | |
} | |
Console.WriteLine("codeVerifier " + codeVerifier + "\n"); | |
Console.WriteLine("codeChallenge " + codeChallenge + "\n"); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://medium.com/the-new-control-plane/using-proof-key-for-code-exchange-pkce-in-adfs-for-windows-server-2019-a457172e28c3