Skip to content

Commit

Permalink
Use IdentityModel 8.0.2 (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanapellanes-okta authored Sep 17, 2024
1 parent 53a4f8a commit e012451
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion API_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Allows customers to easily access the Okta Management APIs
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 5.1.0
- SDK version: 8.1.4
- SDK version: 8.1.5
- Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen
For more information, please visit [https://developer.okta.com/](https://developer.okta.com/)

Expand Down
2 changes: 1 addition & 1 deletion openapi3/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"packageName" : "Okta.Sdk",
"outputDir" : "../",
"inputSpec" : "./management.yaml",
"packageVersion" : "8.1.4",
"packageVersion" : "8.1.5",
"packageDescription" : "Official .NET SDK for the Okta API",
"packageTitle" : "Official .NET SDK for the Okta API",
"packageCompany" : "Okta, Inc.",
Expand Down
7 changes: 4 additions & 3 deletions openapi3/templates/DefaultDpopProofJwtGenerator.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using System.Security.Claims;
using System.Security.Cryptography;
using System.Text;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;

namespace {{packageName}}.Client
{
Expand Down Expand Up @@ -81,12 +82,12 @@ namespace {{packageName}}.Client
{ "jti", Guid.NewGuid().ToString()}
};

if (!nonce.IsNullOrEmpty())
if (!string.IsNullOrEmpty(nonce))
{
payload.AddClaim(new Claim("nonce", nonce));
}

if (!accessToken.IsNullOrEmpty())
if (!string.IsNullOrEmpty(accessToken))
{
payload.AddClaim(new Claim("ath", HashAccessTokenForDpopProof(accessToken)));
}
Expand All @@ -100,7 +101,7 @@ namespace {{packageName}}.Client

var outboundAlgorithmMap = new Dictionary<string, string> { { "alg", SecurityAlgorithms.RsaSha256 } };

var additionalHeaders = new Dictionary<string, object> { { "jwk", publicJsonWebKey } };
var additionalHeaders = new Dictionary<string, object> { { "jwk", JsonConvert.SerializeObject(publicJsonWebKey) } };

var securityToken =
new JwtSecurityToken(
Expand Down
2 changes: 1 addition & 1 deletion openapi3/templates/DefaultOAuthTokenProvider.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace {{packageName}}.Client

request.AddOrUpdateHeader("Authorization", $"{tokenType} {context["access_token"]}");
}
else if (!dpopProofJwt.IsNullOrEmpty()) // If the client retries a request due to a 429 response, we expect the dpopProofJwt not to be null (rate-limit exceeded)
else if (!string.IsNullOrEmpty(dpopProofJwt)) // If the client retries a request due to a 429 response, we expect the dpopProofJwt not to be null (rate-limit exceeded)
{
foreach (var oldDpopHeader in request.Parameters.Where(p => p.Name.Equals("DPoP", StringComparison.OrdinalIgnoreCase)).ToArray())
{
Expand Down
4 changes: 2 additions & 2 deletions openapi3/templates/netcore_project.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Okta.Sdk.Abstractions" Version="4.0.4" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.35.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.35.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.0.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.2" />
{{/useGenericHost}}
{{#useRestSharp}}
<PackageReference Include="RestSharp" Version="112.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions src/Okta.Sdk/Client/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Configuration : IReadableConfiguration
/// Version of the package.
/// </summary>
/// <value>Version of the package.</value>
public const string Version = "8.1.4";
public const string Version = "8.1.5";

/// <summary>
/// Identifier for ISO 8601 DateTime Format
Expand Down Expand Up @@ -766,7 +766,7 @@ public static string ToDebugReport()
report += " OS: " + System.Environment.OSVersion + "\n";
report += " .NET Framework Version: " + System.Environment.Version + "\n";
report += " Version of the API: 5.1.0\n";
report += " SDK Package Version: 8.1.4\n";
report += " SDK Package Version: 8.1.5\n";

return report;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Okta.Sdk/Client/DefaultDpopProofJwtGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Security.Cryptography;
using System.Text;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;

namespace Okta.Sdk.Client
{
Expand Down Expand Up @@ -90,12 +91,12 @@ public string GenerateJwt(String? nonce = null, String? httpMethod = null, Strin
{ "jti", Guid.NewGuid().ToString()}
};

if (!nonce.IsNullOrEmpty())
if (!string.IsNullOrEmpty(nonce))
{
payload.AddClaim(new Claim("nonce", nonce));
}

if (!accessToken.IsNullOrEmpty())
if (!string.IsNullOrEmpty(accessToken))
{
payload.AddClaim(new Claim("ath", HashAccessTokenForDpopProof(accessToken)));
}
Expand All @@ -109,7 +110,7 @@ public string GenerateJwt(String? nonce = null, String? httpMethod = null, Strin

var outboundAlgorithmMap = new Dictionary<string, string> { { "alg", SecurityAlgorithms.RsaSha256 } };

var additionalHeaders = new Dictionary<string, object> { { "jwk", publicJsonWebKey } };
var additionalHeaders = new Dictionary<string, object> { { "jwk", JsonConvert.SerializeObject(publicJsonWebKey) } };

var securityToken =
new JwtSecurityToken(
Expand Down
2 changes: 1 addition & 1 deletion src/Okta.Sdk/Client/DefaultOAuthTokenProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static void AddOrUpdateAuthorizationHeader(Context context, RestRequest r

request.AddOrUpdateHeader("Authorization", $"{tokenType} {context["access_token"]}");
}
else if (!dpopProofJwt.IsNullOrEmpty()) // If the client retries a request due to a 429 response, we expect the dpopProofJwt not to be null (rate-limit exceeded)
else if (!string.IsNullOrEmpty(dpopProofJwt)) // If the client retries a request due to a 429 response, we expect the dpopProofJwt not to be null (rate-limit exceeded)
{
foreach (var oldDpopHeader in request.Parameters.Where(p => p.Name.Equals("DPoP", StringComparison.OrdinalIgnoreCase)).ToArray())
{
Expand Down
6 changes: 3 additions & 3 deletions src/Okta.Sdk/Okta.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Description>Official .NET SDK for the Okta API</Description>
<Copyright>Okta, Inc.</Copyright>
<RootNamespace>Okta.Sdk</RootNamespace>
<Version>8.1.4</Version>
<Version>8.1.5</Version>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Okta.Sdk.xml</DocumentationFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
Expand All @@ -27,8 +27,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Okta.Sdk.Abstractions" Version="4.0.4" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.35.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.35.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.0.2" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.2" />
<PackageReference Include="RestSharp" Version="112.0.0" />
<PackageReference Include="Polly" Version="7.2.3" />
</ItemGroup>
Expand Down

0 comments on commit e012451

Please sign in to comment.