Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List<PublicKeyCredentialDescriptor>/IEnumerable<PublicKeyCredentialDescriptor> to IReadOnlyList<PublicKeyCredentialDescriptor> #447

Merged
merged 10 commits into from
Dec 22, 2023
9 changes: 7 additions & 2 deletions Src/Fido2.Models/AssertionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AssertionOptions : Fido2ResponseBase
/// This OPTIONAL member contains a list of PublicKeyCredentialDescriptor objects representing public key credentials acceptable to the caller, in descending order of the caller’s preference(the first item in the list is the most preferred credential, and so on down the list)
/// </summary>
[JsonPropertyName("allowCredentials")]
public IEnumerable<PublicKeyCredentialDescriptor> AllowCredentials { get; set; }
public IReadOnlyList<PublicKeyCredentialDescriptor> AllowCredentials { get; set; } = new List<PublicKeyCredentialDescriptor>();
abergs marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// This member describes the Relying Party's requirements regarding user verification for the get() operation. Eligible authenticators are filtered to only those capable of satisfying this requirement
Expand All @@ -51,7 +51,12 @@ public class AssertionOptions : Fido2ResponseBase
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public AuthenticationExtensionsClientInputs Extensions { get; set; }

public static AssertionOptions Create(Fido2Configuration config, byte[] challenge, IEnumerable<PublicKeyCredentialDescriptor> allowedCredentials, UserVerificationRequirement? userVerification, AuthenticationExtensionsClientInputs extensions)
public static AssertionOptions Create(
Fido2Configuration config,
byte[] challenge,
IReadOnlyList<PublicKeyCredentialDescriptor> allowedCredentials,
UserVerificationRequirement? userVerification,
AuthenticationExtensionsClientInputs extensions)
{
return new AssertionOptions()
{
Expand Down
19 changes: 13 additions & 6 deletions Src/Fido2.Models/CredentialCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public sealed class CredentialCreateOptions : Fido2ResponseBase
/// This member is intended for use by Relying Parties that wish to express their preference for attestation conveyance.The default is none.
/// </summary>
[JsonPropertyName("attestation")]
public AttestationConveyancePreference Attestation { get; set; } = AttestationConveyancePreference.None;

public AttestationConveyancePreference Attestation { get; set; } = AttestationConveyancePreference.None;
/// <summary>
/// This member is intended for use by Relying Parties that wish to select the appropriate authenticators to participate in the create() operation.
/// </summary>
Expand All @@ -61,7 +61,7 @@ public sealed class CredentialCreateOptions : Fido2ResponseBase
/// This member is intended for use by Relying Parties that wish to limit the creation of multiple credentials for the same account on a single authenticator.The client is requested to return an error if the new credential would be created on an authenticator that also contains one of the credentials enumerated in this parameter.
/// </summary>
[JsonPropertyName("excludeCredentials")]
public List<PublicKeyCredentialDescriptor> ExcludeCredentials { get; set; }
public IReadOnlyList<PublicKeyCredentialDescriptor> ExcludeCredentials { get; set; } = new List<PublicKeyCredentialDescriptor>();
abergs marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// This OPTIONAL member contains additional parameters requesting additional processing by the client and authenticator. For example, if transaction confirmation is sought from the user, then the prompt string might be included as an extension.
Expand All @@ -70,7 +70,14 @@ public sealed class CredentialCreateOptions : Fido2ResponseBase
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public AuthenticationExtensionsClientInputs Extensions { get; set; }

public static CredentialCreateOptions Create(Fido2Configuration config, byte[] challenge, Fido2User user, AuthenticatorSelection authenticatorSelection, AttestationConveyancePreference attestationConveyancePreference, List<PublicKeyCredentialDescriptor> excludeCredentials, AuthenticationExtensionsClientInputs extensions)
public static CredentialCreateOptions Create(
Fido2Configuration config,
byte[] challenge,
Fido2User user,
AuthenticatorSelection authenticatorSelection,
AttestationConveyancePreference attestationConveyancePreference,
IReadOnlyList<PublicKeyCredentialDescriptor> excludeCredentials,
AuthenticationExtensionsClientInputs extensions)
{
return new CredentialCreateOptions
{
Expand All @@ -96,7 +103,7 @@ public static CredentialCreateOptions Create(Fido2Configuration config, byte[] c
},
AuthenticatorSelection = authenticatorSelection,
Attestation = attestationConveyancePreference,
ExcludeCredentials = excludeCredentials ?? new List<PublicKeyCredentialDescriptor>(),
ExcludeCredentials = excludeCredentials ?? Array.Empty<PublicKeyCredentialDescriptor>(),
abergs marked this conversation as resolved.
Show resolved Hide resolved
Extensions = extensions
};
}
Expand Down Expand Up @@ -225,7 +232,7 @@ public ResidentKeyRequirement ResidentKey
/// </summary>
[Obsolete("Use property ResidentKey.")]
[JsonPropertyName("requireResidentKey")]
public bool RequireResidentKey
public bool RequireResidentKey
{
get => _requireResidentKey;
set
Expand Down
6 changes: 3 additions & 3 deletions Src/Fido2/Fido2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Fido2(
/// <param name="excludeCredentials">Recommended. This member is intended for use by Relying Parties that wish to limit the creation of multiple credentials for the same account on a single authenticator.The client is requested to return an error if the new credential would be created on an authenticator that also contains one of the credentials enumerated in this parameter.</param>
public CredentialCreateOptions RequestNewCredential(
Fido2User user,
List<PublicKeyCredentialDescriptor> excludeCredentials,
IReadOnlyList<PublicKeyCredentialDescriptor> excludeCredentials,
AuthenticationExtensionsClientInputs? extensions = null)
{
return RequestNewCredential(user, excludeCredentials, AuthenticatorSelection.Default, AttestationConveyancePreference.None, extensions);
Expand All @@ -44,7 +44,7 @@ public CredentialCreateOptions RequestNewCredential(
/// <param name="excludeCredentials">Recommended. This member is intended for use by Relying Parties that wish to limit the creation of multiple credentials for the same account on a single authenticator.The client is requested to return an error if the new credential would be created on an authenticator that also contains one of the credentials enumerated in this parameter.</param>
public CredentialCreateOptions RequestNewCredential(
Fido2User user,
List<PublicKeyCredentialDescriptor> excludeCredentials,
IReadOnlyList<PublicKeyCredentialDescriptor> excludeCredentials,
AuthenticatorSelection authenticatorSelection,
AttestationConveyancePreference attestationPreference,
AuthenticationExtensionsClientInputs? extensions = null)
Expand Down Expand Up @@ -84,7 +84,7 @@ public async Task<CredentialMakeResult> MakeNewCredentialAsync(
/// </summary>
/// <returns></returns>
public AssertionOptions GetAssertionOptions(
IEnumerable<PublicKeyCredentialDescriptor> allowedCredentials,
IReadOnlyList<PublicKeyCredentialDescriptor> allowedCredentials,
UserVerificationRequirement? userVerification,
AuthenticationExtensionsClientInputs? extensions = null)
{
Expand Down
8 changes: 4 additions & 4 deletions Src/Fido2/IFido2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace Fido2NetLib;
public interface IFido2
{
AssertionOptions GetAssertionOptions(
IEnumerable<PublicKeyCredentialDescriptor> allowedCredentials,
UserVerificationRequirement? userVerification,
IReadOnlyList<PublicKeyCredentialDescriptor> allowedCredentials,
UserVerificationRequirement? userVerification,
AuthenticationExtensionsClientInputs? extensions = null);

Task<VerifyAssertionResult> MakeAssertionAsync(
Expand All @@ -30,12 +30,12 @@ Task<VerifyAssertionResult> MakeAssertionAsync(

CredentialCreateOptions RequestNewCredential(
Fido2User user,
List<PublicKeyCredentialDescriptor> excludeCredentials,
IReadOnlyList<PublicKeyCredentialDescriptor> excludeCredentials,
AuthenticationExtensionsClientInputs? extensions = null);

CredentialCreateOptions RequestNewCredential(
Fido2User user,
List<PublicKeyCredentialDescriptor> excludeCredentials,
IReadOnlyList<PublicKeyCredentialDescriptor> excludeCredentials,
AuthenticatorSelection authenticatorSelection,
AttestationConveyancePreference attestationPreference,
AuthenticationExtensionsClientInputs? extensions = null);
Expand Down