From d6324086ce1664bdfbc020f36d6ed0fbec69688c Mon Sep 17 00:00:00 2001 From: pgermishuys Date: Fri, 17 Oct 2025 09:23:40 +0200 Subject: [PATCH] Rectify Base64 related Encoding and Decoding method calls --- Directory.Packages.props | 2 +- .../Hosts.IdentityServer/Pages/Diagnostics/ViewModel.cs | 3 ++- .../RemoteApis/Hosts.RemoteApi.DPoP/DPoP/DPoPExtensions.cs | 3 ++- .../Hosts.RemoteApi.DPoP/DPoP/DPoPProofValidator.cs | 5 +++-- bff/src/Bff.Yarp/Bff.Yarp.csproj | 1 - 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index f8d22ae01..9c0fc866a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -74,7 +74,7 @@ - + diff --git a/bff/hosts/Hosts.IdentityServer/Pages/Diagnostics/ViewModel.cs b/bff/hosts/Hosts.IdentityServer/Pages/Diagnostics/ViewModel.cs index 58bde0f7c..c990771a4 100644 --- a/bff/hosts/Hosts.IdentityServer/Pages/Diagnostics/ViewModel.cs +++ b/bff/hosts/Hosts.IdentityServer/Pages/Diagnostics/ViewModel.cs @@ -2,6 +2,7 @@ // See LICENSE in the project root for license information. +using System.Buffers.Text; using System.Text; using System.Text.Json; using Duende.IdentityModel; @@ -18,7 +19,7 @@ public class ViewModel if (result.Properties.Items.ContainsKey("client_list")) { var encoded = result.Properties.Items["client_list"]; - var bytes = Base64Url.Decode(encoded); + var bytes = Base64Url.DecodeFromChars(encoded); var value = Encoding.UTF8.GetString(bytes); Clients = JsonSerializer.Deserialize(value); diff --git a/bff/hosts/RemoteApis/Hosts.RemoteApi.DPoP/DPoP/DPoPExtensions.cs b/bff/hosts/RemoteApis/Hosts.RemoteApi.DPoP/DPoP/DPoPExtensions.cs index 62febb426..e9e0faad1 100644 --- a/bff/hosts/RemoteApis/Hosts.RemoteApi.DPoP/DPoP/DPoPExtensions.cs +++ b/bff/hosts/RemoteApis/Hosts.RemoteApi.DPoP/DPoP/DPoPExtensions.cs @@ -1,6 +1,7 @@ // Copyright (c) Duende Software. All rights reserved. // See LICENSE in the project root for license information. +using System.Buffers.Text; using System.Text.Json; using Duende.IdentityModel; using Microsoft.AspNetCore.Authentication; @@ -66,7 +67,7 @@ internal static class DPoPExtensions /// public static string CreateThumbprint(this JsonWebKey jwk) { - var jkt = Base64Url.Encode(jwk.ComputeJwkThumbprint()); + var jkt = Base64Url.EncodeToString(jwk.ComputeJwkThumbprint()); return jkt; } } diff --git a/bff/hosts/RemoteApis/Hosts.RemoteApi.DPoP/DPoP/DPoPProofValidator.cs b/bff/hosts/RemoteApis/Hosts.RemoteApi.DPoP/DPoP/DPoPProofValidator.cs index c43a805b3..021a1ed71 100644 --- a/bff/hosts/RemoteApis/Hosts.RemoteApi.DPoP/DPoP/DPoPProofValidator.cs +++ b/bff/hosts/RemoteApis/Hosts.RemoteApi.DPoP/DPoP/DPoPProofValidator.cs @@ -1,6 +1,7 @@ // Copyright (c) Duende Software. All rights reserved. // See LICENSE in the project root for license information. +using System.Buffers.Text; using System.Security.Cryptography; using System.Text; using System.Text.Json; @@ -226,7 +227,7 @@ public class DPoPProofValidator var bytes = Encoding.UTF8.GetBytes(context.AccessToken); var hash = sha.ComputeHash(bytes); - var accessTokenHash = Base64Url.Encode(hash); + var accessTokenHash = Base64Url.EncodeToString(hash); if (accessTokenHash != result.AccessTokenHash) { result.IsError = true; @@ -328,7 +329,7 @@ public class DPoPProofValidator skew = dpopOptions.ServerClockSkew; } - // we do x2 here because clock might be might be before or after, so we're making cache duration + // we do x2 here because clock might be might be before or after, so we're making cache duration // longer than the likelyhood of proof token expiration, which is done before replay skew *= 2; var cacheDuration = dpopOptions.ProofTokenValidityDuration + skew; diff --git a/bff/src/Bff.Yarp/Bff.Yarp.csproj b/bff/src/Bff.Yarp/Bff.Yarp.csproj index b251f23b3..86d1580d0 100644 --- a/bff/src/Bff.Yarp/Bff.Yarp.csproj +++ b/bff/src/Bff.Yarp/Bff.Yarp.csproj @@ -6,7 +6,6 @@ -