Skip to content

Commit

Permalink
Use WebEncoders.Base64UrlEncode()
Browse files Browse the repository at this point in the history
Use WebEncoders.Base64UrlEncode() instead of Base64UrlTextEncoder.Encode().
  • Loading branch information
martincostello committed Jan 6, 2022
1 parent c39cb66 commit 9efb439
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p
if (Options.UsePkce)
{
byte[] bytes = RandomNumberGenerator.GetBytes(32);
string codeVerifier = Microsoft.AspNetCore.WebUtilities.Base64UrlTextEncoder.Encode(bytes);
string codeVerifier = WebEncoders.Base64UrlEncode(bytes);

// Store this for use during the code redemption.
properties.Items.Add(OAuthConstants.CodeVerifierKey, codeVerifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p
if (Options.UsePkce)
{
byte[] bytes = RandomNumberGenerator.GetBytes(32);
string codeVerifier = Microsoft.AspNetCore.WebUtilities.Base64UrlTextEncoder.Encode(bytes);
string codeVerifier = WebEncoders.Base64UrlEncode(bytes);

// Store this for use during the code redemption.
properties.Items.Add(OAuthConstants.CodeVerifierKey, codeVerifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Base64UrlTextEncoder = Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder;

namespace AspNet.Security.OAuth.Mixcloud;

Expand Down Expand Up @@ -43,7 +42,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p
if (Options.UsePkce)
{
var bytes = RandomNumberGenerator.GetBytes(32);
var codeVerifier = Base64UrlTextEncoder.Encode(bytes);
var codeVerifier = WebEncoders.Base64UrlEncode(bytes);

// Store this for use during the code redemption.
properties.Items.Add(OAuthConstants.CodeVerifierKey, codeVerifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p
if (Options.UsePkce)
{
byte[] bytes = RandomNumberGenerator.GetBytes(32);
string codeVerifier = Microsoft.AspNetCore.WebUtilities.Base64UrlTextEncoder.Encode(bytes);
string codeVerifier = WebEncoders.Base64UrlEncode(bytes);

// Store this for use during the code redemption.
properties.Items.Add(OAuthConstants.CodeVerifierKey, codeVerifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p
if (Options.UsePkce)
{
var bytes = RandomNumberGenerator.GetBytes(32);
var codeVerifier = Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder.Encode(bytes);
var codeVerifier = WebEncoders.Base64UrlEncode(bytes);

// Store this for use during the code redemption.
properties.Items.Add(OAuthConstants.CodeVerifierKey, codeVerifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected override string BuildChallengeUrl([NotNull] AuthenticationProperties p
if (Options.UsePkce)
{
var bytes = RandomNumberGenerator.GetBytes(32);
var codeVerifier = Microsoft.AspNetCore.Authentication.Base64UrlTextEncoder.Encode(bytes);
var codeVerifier = WebEncoders.Base64UrlEncode(bytes);

// Store this for use during the code redemption.
properties.Items.Add(OAuthConstants.CodeVerifierKey, codeVerifier);
Expand Down

0 comments on commit 9efb439

Please sign in to comment.