Skip to content

Commit

Permalink
Missing data in verifyFactorRequest prevents verifying webauthn (#688)
Browse files Browse the repository at this point in the history
- Add missing properties to VerifyFactorRequest
- Add additional properties to VerifyUserFactorResponse
- Update project's version
- Fix test
  • Loading branch information
laura-rodriguez committed Jan 9, 2024
1 parent 3afa851 commit 1e1cae0
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 10 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: 7.0.2
- SDK version: 7.0.3
- Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen
For more information, please visit [https://developer.okta.com/](https://developer.okta.com/)

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog
Running changelog of releases since `3.1.1`

## 7.0.3

- Fix "Missing data in verifyFactorRequest prevents verifying webauthn" (OKTA-656179)

## 7.0.2

- Fix "JTI Claim as a string instead of guid" (#682)

## 7.0.1

- Fix "Incosistent Exception Handling" issue (#658)
Expand Down
2 changes: 2 additions & 0 deletions docs/VerifyFactorRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Name | Type | Description | Notes
**PassCode** | **string** | | [optional]
**RegistrationData** | **string** | | [optional]
**StateToken** | **string** | | [optional]
**AuthenticatorData** | **string** | | [optional]
**SignatureData** | **string** | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

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" : "7.0.2",
"packageVersion" : "7.0.3",
"packageDescription" : "Official .NET SDK for the Okta API",
"packageTitle" : "Official .NET SDK for the Okta API",
"packageCompany" : "Okta, Inc.",
Expand Down
7 changes: 7 additions & 0 deletions openapi3/management.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31801,6 +31801,12 @@ components:
type: string
stateToken:
type: string
clientData:
type: string
authenticatorData:
type: string
signatureData:
type: string
VerifyUserFactorResponseLinks:
type: object
properties:
Expand All @@ -31812,6 +31818,7 @@ components:
$ref: '#/components/schemas/HrefObject'
VerifyUserFactorResponse:
type: object
additionalProperties: true
properties:
expiresAt:
type: string
Expand Down
35 changes: 33 additions & 2 deletions src/Okta.Sdk.UnitTest/Api/UserFactorApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using WireMock.Server;
using Okta.Sdk.Model;
using NJsonSchema.Extensions;
using WireMock.ResponseBuilders;
using Newtonsoft.Json.Linq;

namespace Okta.Sdk.UnitTest.Api
{
Expand Down Expand Up @@ -193,7 +195,7 @@ public async Task EnrollSymantecFactor()
NextPassCode = "foo",
}
});

mockClient.ReceivedBody.Should().BeEquivalentTo("{\"profile\":{\"credentialId\":\"foo\"},\"factorType\":\"token\",\"provider\":\"SYMANTEC\",\"verify\":{\"nextPassCode\":\"foo\",\"passCode\":\"foo\"}}");
enrollFactorResponse.FactorType.Should().Be(FactorType.Token);
enrollFactorResponse.Provider.Should().Be(FactorProvider.SYMANTEC);
Expand Down Expand Up @@ -313,7 +315,7 @@ public async Task EnrollOVFactor()
var mockClient = new MockAsyncClient(response, HttpStatusCode.OK);
var userFactorApi = new UserFactorApi(mockClient, new Configuration { BasePath = "https://foo.com" });

var enrollFactorResponse = await userFactorApi.EnrollFactorAsync("foo",
var enrollFactorResponse = await userFactorApi.EnrollFactorAsync("foo",
new EmailUserFactor
{
FactorType = FactorType.Email,
Expand Down Expand Up @@ -389,5 +391,34 @@ public async Task EnrollCustomTotpFactor()
enrollFactorResponse.FactorType.Should().Be(FactorType.Tokenhotp);
enrollFactorResponse.Provider.Should().Be(FactorProvider.CUSTOM);
}

[Fact]
public async Task VerifyWebAuthnFactor()
{
var response = @"{
""factorResult"":""SUCCESS"",
""profile"":{
""credentialId"":""l3Br0n-7H3g047NqESqJynFtIgf3Ix9OfaRoNwLoloso99Xl2zS_O7EXUkmPeAIzTVtEL4dYjicJWBz7NpqhGA"",
""authenticatorName"":""MacBook Touch ID""
}
}";

var mockClient = new MockAsyncClient(response, HttpStatusCode.OK);
var userFactorApi = new UserFactorApi(mockClient, new Configuration { BasePath = "https://foo.com" });

var verifyFactorRequest = new VerifyFactorRequest
{
ClientData = "foo",
AuthenticatorData = "bar",
SignatureData = "baz",
};

var verifyResponse = await userFactorApi.VerifyFactorAsync("bax", "pcm", body: verifyFactorRequest);
mockClient.ReceivedBody.Should().BeEquivalentTo("{\"clientData\":\"foo\",\"authenticatorData\":\"bar\",\"signatureData\":\"baz\"}");
verifyResponse.FactorResult.Should().Be(VerifyUserFactorResult.SUCCESS);
var profile = (JObject)verifyResponse.AdditionalProperties["profile"];
profile["credentialId"].ToString().Should().Be("l3Br0n-7H3g047NqESqJynFtIgf3Ix9OfaRoNwLoloso99Xl2zS_O7EXUkmPeAIzTVtEL4dYjicJWBz7NpqhGA");
profile["authenticatorName"].ToString().Should().Be("MacBook Touch ID");
}
}
}
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 = "7.0.2";
public const string Version = "7.0.3";

/// <summary>
/// Identifier for ISO 8601 DateTime Format
Expand Down Expand Up @@ -758,7 +758,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: 7.0.2\n";
report += " SDK Package Version: 7.0.3\n";

return report;
}
Expand Down
32 changes: 32 additions & 0 deletions src/Okta.Sdk/Model/VerifyFactorRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ public partial class VerifyFactorRequest : IEquatable<VerifyFactorRequest>
[DataMember(Name = "stateToken", EmitDefaultValue = true)]
public string StateToken { get; set; }

/// <summary>
/// Gets or Sets AuthenticatorData
/// </summary>
[DataMember(Name = "authenticatorData", EmitDefaultValue = true)]
public string AuthenticatorData { get; set; }

/// <summary>
/// Gets or Sets SignatureData
/// </summary>
[DataMember(Name = "signatureData", EmitDefaultValue = true)]
public string SignatureData { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand All @@ -98,6 +110,8 @@ public override string ToString()
sb.Append(" PassCode: ").Append(PassCode).Append("\n");
sb.Append(" RegistrationData: ").Append(RegistrationData).Append("\n");
sb.Append(" StateToken: ").Append(StateToken).Append("\n");
sb.Append(" AuthenticatorData: ").Append(AuthenticatorData).Append("\n");
sb.Append(" SignatureData: ").Append(SignatureData).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
Expand Down Expand Up @@ -172,6 +186,16 @@ public bool Equals(VerifyFactorRequest input)
this.StateToken == input.StateToken ||
(this.StateToken != null &&
this.StateToken.Equals(input.StateToken))
) &&
(
this.AuthenticatorData == input.AuthenticatorData ||
(this.AuthenticatorData != null &&
this.AuthenticatorData.Equals(input.AuthenticatorData))
) &&
(
this.SignatureData == input.SignatureData ||
(this.SignatureData != null &&
this.SignatureData.Equals(input.SignatureData))
);
}

Expand Down Expand Up @@ -217,6 +241,14 @@ public override int GetHashCode()
{
hashCode = (hashCode * 59) + this.StateToken.GetHashCode();
}
if (this.AuthenticatorData != null)
{
hashCode = (hashCode * 59) + this.AuthenticatorData.GetHashCode();
}
if (this.SignatureData != null)
{
hashCode = (hashCode * 59) + this.SignatureData.GetHashCode();
}
return hashCode;
}
}
Expand Down
18 changes: 15 additions & 3 deletions src/Okta.Sdk/Model/VerifyUserFactorResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ namespace Okta.Sdk.Model
/// VerifyUserFactorResponse
/// </summary>
[DataContract(Name = "VerifyUserFactorResponse")]

public partial class VerifyUserFactorResponse : IEquatable<VerifyUserFactorResponse>

{

/// <summary>
Expand Down Expand Up @@ -81,6 +81,12 @@ public bool ShouldSerializeEmbedded()
[DataMember(Name = "_links", EmitDefaultValue = true)]
public VerifyUserFactorResponseLinks Links { get; set; }

/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand All @@ -94,6 +100,7 @@ public override string ToString()
sb.Append(" FactorResultMessage: ").Append(FactorResultMessage).Append("\n");
sb.Append(" Embedded: ").Append(Embedded).Append("\n");
sb.Append(" Links: ").Append(Links).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
Expand All @@ -102,7 +109,7 @@ public override string ToString()
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public virtual string ToJson()
public string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
}
Expand Down Expand Up @@ -153,7 +160,8 @@ public bool Equals(VerifyUserFactorResponse input)
this.Links == input.Links ||
(this.Links != null &&
this.Links.Equals(input.Links))
);
)
&& (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any());
}

/// <summary>
Expand Down Expand Up @@ -186,6 +194,10 @@ public override int GetHashCode()
{
hashCode = (hashCode * 59) + this.Links.GetHashCode();
}
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Okta.Sdk/Okta.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Description>Official .NET SDK for the Okta API</Description>
<Copyright>Okta, Inc.</Copyright>
<RootNamespace>Okta.Sdk</RootNamespace>
<Version>7.0.2</Version>
<Version>7.0.3</Version>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Okta.Sdk.xml</DocumentationFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
Expand Down

0 comments on commit 1e1cae0

Please sign in to comment.