Skip to content

Commit

Permalink
Merge pull request #316 from sujitharamadass/MayRelease
Browse files Browse the repository at this point in the history
Changing validateIDToken logic to include 2048 key signing
  • Loading branch information
sujitharamadass authored Jul 28, 2023
2 parents d935816 + 042e71d commit bc13280
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions IPPDotNetDevKitCSV3/Code/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<PackageIcon>$(MSBuildThisFileDirectory)logo.png</PackageIcon>
<OutputPath>$(SolutionDir)artifacts\bin</OutputPath>
<Copyright>Copyright © 2020 Intuit, Inc.</Copyright>
<AssemblyVersion>14.6.3.5</AssemblyVersion>
<FileVersion>14.6.3.4</FileVersion>
<AssemblyVersion>14.6.3.6</AssemblyVersion>
<FileVersion>14.6.3.6</FileVersion>
<Company>Intuit</Company>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageId>IppDotNetSdkForQuickBooksApiV3</PackageId>
<AssemblyName>IppDotNetSdkForQuickBooksApiV3</AssemblyName>
<DocumentationFile>$(BaseOutputPath)$(AssemblyName).xml</DocumentationFile>
<MainVersion>14.6.3.5</MainVersion>
<MainVersion>14.6.3.6</MainVersion>
<PackageVersionSuffix>pre</PackageVersionSuffix>
<Version>$(MainVersion)-$(PackageVersionSuffix)</Version>
<Version>$(MainVersion)</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,29 +875,19 @@ public Task<bool> ValidateIDTokenAsync(String idToken)
IList<JsonWebKey> keys = DiscoveryDoc.KeySet.Keys;
string mod = "";
string exponent = "";
string keyIdFromHeader = null;
if (keys != null)
{
foreach (var key in keys)
{
if (key.N != null)
{
mod = key.N;
}
if (key.N != null)
{
exponent = key.E;
}
}

if (idToken != null)
{
string[] splitValues = idToken.Split('.');
if (splitValues[0] != null)
{
var headerJson = Encoding.UTF8.GetString(Base64Url.Decode(splitValues[0].ToString()));
IdTokenHeader headerData = JsonConvert.DeserializeObject<IdTokenHeader>(headerJson);
keyIdFromHeader = headerData.Kid;

if (headerData.Kid == null)
if (keyIdFromHeader == null)
{
return Task.FromResult(false);
}
Expand Down Expand Up @@ -965,6 +955,21 @@ public Task<bool> ValidateIDTokenAsync(String idToken)
}
}

foreach (var key in keys)
{
if(keyIdFromHeader == key.Kid)
{
if (key.N != null)
{
mod = key.N;
}
if (key.N != null)
{
exponent = key.E;
}
}
}

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.ImportParameters(
new RSAParameters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public static class CoreConstants
/// <summary>
/// The Request source header value.
/// </summary>
public const string REQUESTSOURCEHEADER = "V3DotNetSDK14.6.3.5";
public const string REQUESTSOURCEHEADER = "V3DotNetSDK14.6.3.6";

/// <summary>
/// multipart/form-data format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<PackageOutputPath>$(SolutionDir)artifacts\nupkg</PackageOutputPath>
<OutputPath>$(SolutionDir)artifacts\bin</OutputPath>
<Copyright>Copyright © 2020 Intuit, Inc.</Copyright>
<AssemblyVersion>14.6.3.4</AssemblyVersion>
<FileVersion>14.6.3.4</FileVersion>
<AssemblyVersion>14.6.3.6</AssemblyVersion>
<FileVersion>14.6.3.6</FileVersion>
<Company>Intuit</Company>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
Expand Down

0 comments on commit bc13280

Please sign in to comment.