Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!-- Global Variables -->
<PropertyGroup>
<SupportedTargetFrameworks>net8.0</SupportedTargetFrameworks>
<SupportedTargetFrameworks>net8.0;net10.0</SupportedTargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -29,7 +29,7 @@

<!-- Language + Compiler Settings-->
<PropertyGroup>
<LangVersion>12</LangVersion>
<LangVersion>13</LangVersion>
</PropertyGroup>

<!--MISC-->
Expand Down
9 changes: 7 additions & 2 deletions Src/Fido2.Models/Converters/EnumNameMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace Fido2NetLib;

Expand Down Expand Up @@ -45,11 +46,15 @@ private static FrozenDictionary<TEnum, string> GetIdToNameMap()

foreach (var field in typeof(TEnum).GetFields(BindingFlags.Public | BindingFlags.Static))
{
var description = field.GetCustomAttribute<EnumMemberAttribute>(false);
#if NET9_0_OR_GREATER
var description = field.GetCustomAttribute<JsonStringEnumMemberNameAttribute>(false)?.Name;
#else
var description = field.GetCustomAttribute<EnumMemberAttribute>(false)?.Value;
#endif

var value = (TEnum)field.GetValue(null)!;

items.Add(new(value, description is not null ? description.Value! : value.ToString()));
items.Add(new(value, description ?? value.ToString()));
}

return items.ToFrozenDictionary();
Expand Down
13 changes: 13 additions & 0 deletions Src/Fido2.Models/Fido2Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable disable

using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace Fido2NetLib;

Expand Down Expand Up @@ -114,19 +115,31 @@ public enum CredentialBackupPolicy
/// <summary>
/// This value indicates that the Relying Party requires backup eligible or backed up credentials.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("required")]
#else
[EnumMember(Value = "required")]
#endif
Required,

/// <summary>
/// This value indicates that the Relying Party allows backup eligible or backed up credentials.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("allowed")]
#else
[EnumMember(Value = "allowed")]
#endif
Allowed,

/// <summary>
/// This value indicates that the Relying Party does not allow backup eligible or backed up credentials.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("disallowed")]
#else
[EnumMember(Value = "disallowed")]
#endif
Disallowed
}
}
56 changes: 56 additions & 0 deletions Src/Fido2.Models/Metadata/UserVerificationMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,128 @@ namespace Fido2NetLib;
*
* https://fidoalliance.org/specs/fido-uaf-v1.0-ps-20141208/fido-uaf-reg-v1.0-ps-20141208.html#user-verification-methods
*/
#if NET9_0_OR_GREATER
[JsonConverter(typeof(JsonStringEnumConverter<UserVerificationMethods>))]
#else
[JsonConverter(typeof(FidoEnumConverter<UserVerificationMethods>))]
#endif
public enum UserVerificationMethods
{
/// <summary>
/// This flag must be set if the authenticator is able to confirm user presence in any fashion. If this flag and no other is set for user verification, the guarantee is only that the authenticator cannot be operated without some human intervention, not necessarily that the presence verification provides any level of authentication of the human's identity. (e.g. a device that requires a touch to activate)
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("presence_internal")]
#else
[EnumMember(Value = "presence_internal")]
#endif
PRESENCE_INTERNAL = 1,
/// <summary>
/// This flag must be set if the authenticator uses any type of measurement of a fingerprint for user verification.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("fingerprint_internal")]
#else
[EnumMember(Value = "fingerprint_internal")]
#endif
FINGERPRINT_INTERNAL = 2,
/// <summary>
/// This flag must be set if the authenticator uses a local-only passcode (i.e. a passcode not known by the server) for user verification.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("passcode_internal")]
#else
[EnumMember(Value = "passcode_internal")]
#endif
PASSCODE_INTERNAL = 4,
/// <summary>
/// This flag must be set if the authenticator uses a voiceprint (also known as speaker recognition) for user verification.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("voiceprint_internal")]
#else
[EnumMember(Value = "voiceprint_internal")]
#endif
VOICEPRINT_INTERNAL = 8,
/// <summary>
/// This flag must be set if the authenticator uses any manner of face recognition to verify the user.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("faceprint_internal")]
#else
[EnumMember(Value = "faceprint_internal")]
#endif
FACEPRINT_INTERNAL = 0x10,
/// <summary>
/// This flag must be set if the authenticator uses any form of location sensor or measurement for user verification.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("location_internal")]
#else
[EnumMember(Value = "location_internal")]
#endif
LOCATION_INTERNAL = 0x20,
/// <summary>
/// This flag must be set if the authenticator uses any form of eye biometrics for user verification.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("eyeprint_internal")]
#else
[EnumMember(Value = "eyeprint_internal")]
#endif
EYEPRINT_INTERNAL = 0x40,
/// <summary>
/// This flag must be set if the authenticator uses a drawn pattern for user verification.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("pattern_internal")]
#else
[EnumMember(Value = "pattern_internal")]
#endif
PATTERN_INTERNAL = 0x80,
/// <summary>
/// This flag must be set if the authenticator uses any measurement of a full hand (including palm-print, hand geometry or vein geometry) for user verification.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("handprint_internal")]
#else
[EnumMember(Value = "handprint_internal")]
#endif
HANDPRINT_INTERNAL = 0x100,
/// <summary>
/// This flag must be set if the authenticator uses a local-only passcode (i.e. a passcode not known by the server) for user verification that might be gathered outside the authenticator boundary.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("passcode_external")]
#else
[EnumMember(Value = "passcode_external")]
#endif
PASSCODE_EXTERNAL = 0x800,
/// <summary>
/// This flag must be set if the authenticator uses a drawn pattern for user verification that might be gathered outside the authenticator boundary.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("pattern_external")]
#else
[EnumMember(Value = "pattern_external")]
#endif
PATTERN_EXTERNAL = 0x1000,
/// <summary>
/// This flag must be set if the authenticator will respond without any user interaction (e.g. Silent Authenticator).
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("none")]
#else
[EnumMember(Value = "none")]
#endif
NONE = 0x200,
/// <summary>
/// If an authenticator sets multiple flags for user verification types, it may also set this flag to indicate that all verification methods will be enforced (e.g. faceprint AND voiceprint). If flags for multiple user verification methods are set and this flag is not set, verification with only one is necessary (e.g. fingerprint OR passcode).
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("all")]
#else
[EnumMember(Value = "all")]
#endif
ALL = 0x400,
}
20 changes: 20 additions & 0 deletions Src/Fido2.Models/Objects/AttestationConveyancePreference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,51 @@ namespace Fido2NetLib.Objects;
/// AttestationConveyancePreference
/// https://www.w3.org/TR/webauthn-2/#enum-attestation-convey
/// </summary>
#if NET9_0_OR_GREATER
[JsonConverter(typeof(JsonStringEnumConverter<AttestationConveyancePreference>))]
#else
[JsonConverter(typeof(FidoEnumConverter<AttestationConveyancePreference>))]
#endif
public enum AttestationConveyancePreference
{
/// <summary>
/// This value indicates that the Relying Party is not interested in authenticator attestation. For example, in order to potentially avoid having to obtain user consent to relay identifying information to the Relying Party, or to save a roundtrip to an Attestation CA.
/// This is the default value.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("none")]
#else
[EnumMember(Value = "none")]
#endif
None,

/// <summary>
/// This value indicates that the Relying Party prefers an attestation conveyance yielding verifiable attestation statements, but allows the client to decide how to obtain such attestation statements. The client MAY replace the authenticator-generated attestation statements with attestation statements generated by an Anonymization CA, in order to protect the user’s privacy, or to assist Relying Parties with attestation verification in a heterogeneous ecosystem.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("indirect")]
#else
[EnumMember(Value = "indirect")]
#endif
Indirect,

/// <summary>
/// This value indicates that the Relying Party wants to receive the attestation statement as generated by the authenticator.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("direct")]
#else
[EnumMember(Value = "direct")]
#endif
Direct,

/// <summary>
/// This value indicates that the Relying Party wants to receive an attestation statement that may include uniquely identifying information.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("enterprise")]
#else
[EnumMember(Value = "enterprise")]
#endif
Enterprise
}
32 changes: 32 additions & 0 deletions Src/Fido2.Models/Objects/AttestationStatementFormatIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,81 @@ namespace Fido2NetLib.Objects;
/// The attestation statement format identifier in WebAuthn specifies the format of the attestation statement that is used to attest to the authenticity of a credential created by a WebAuthn authenticator.
/// https://www.iana.org/assignments/webauthn/webauthn.xhtml
/// </summary>
#if NET9_0_OR_GREATER
[JsonConverter(typeof(JsonStringEnumConverter<AttestationStatementFormatIdentifier>))]
#else
[JsonConverter(typeof(FidoEnumConverter<AttestationStatementFormatIdentifier>))]
#endif
public enum AttestationStatementFormatIdentifier
{
/// <summary>
/// The "packed" attestation statement format is a WebAuthn-optimized format for attestation. It uses a very compact but still extensible encoding method. This format is implementable by authenticators with limited resources (e.g., secure elements).
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("packed")]
#else
[EnumMember(Value = "packed")]
#endif
Packed,

/// <summary>
/// The "TPM" attestation statement format returns an attestation statement in the same format as the packed attestation statement format, although the rawData and signature fields are computed differently.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("tpm")]
#else
[EnumMember(Value = "tpm")]
#endif
Tpm,

/// <summary>
/// Platform authenticators on versions "N", and later, may provide this proprietary "hardware attestation" statement.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("android-key")]
#else
[EnumMember(Value = "android-key")]
#endif
AndroidKey,

/// <summary>
/// Android-based platform authenticators MAY produce an attestation statement based on the Android SafetyNet API.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("android-safetynet")]
#else
[EnumMember(Value = "android-safetynet")]
#endif
AndroidSafetyNet,

/// <summary>
/// Used with FIDO U2F authenticators.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("fido-u2f")]
#else
[EnumMember(Value = "fido-u2f")]
#endif
FidoU2f,

/// <summary>
/// Used with Apple devices' platform authenticators.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("apple")]
#else
[EnumMember(Value = "apple")]
#endif
Apple,

/// <summary>
/// Used to replace any authenticator-provided attestation statement when a WebAuthn Relying Party indicates it does not wish to receive attestation information.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("none")]
#else
[EnumMember(Value = "none")]
#endif
None
}

12 changes: 12 additions & 0 deletions Src/Fido2.Models/Objects/AuthenticatorAttachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,30 @@ namespace Fido2NetLib.Objects;
/// Note: An authenticator attachment modality selection option is available only in the [[Create]](origin, options, sameOriginWithAncestors) operation. The Relying Party may use it to, for example, ensure the user has a roaming credential for authenticating on another client device; or to specifically register a platform credential for easier reauthentication using a particular client device. The [[DiscoverFromExternalSource]](origin, options, sameOriginWithAncestors) operation has no authenticator attachment modality selection option, so the Relying Party SHOULD accept any of the user’s registered credentials. The client and user will then use whichever is available and convenient at the time.
/// https://www.w3.org/TR/webauthn-2/#enum-attachment
/// </remarks>
#if NET9_0_OR_GREATER
[JsonConverter(typeof(JsonStringEnumConverter<AuthenticatorAttachment>))]
#else
[JsonConverter(typeof(FidoEnumConverter<AuthenticatorAttachment>))]
#endif
public enum AuthenticatorAttachment
{
/// <summary>
/// This value indicates platform attachment
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("platform")]
#else
[EnumMember(Value = "platform")]
#endif
Platform,

/// <summary>
/// This value indicates cross-platform attachment.
/// </summary>
#if NET9_0_OR_GREATER
[JsonStringEnumMemberName("cross-platform")]
#else
[EnumMember(Value = "cross-platform")]
#endif
CrossPlatform
}
Loading
Loading