Skip to content

Commit bd8536f

Browse files
committed
Add AddMetadataRepository<T>
1 parent 78ac222 commit bd8536f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Src/Fido2.AspNet/Fido2NetLibBuilderExtensions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,25 @@ public static IFido2NetLibBuilder AddCachedMetadataService(this IFido2NetLibBuil
108108
return builder;
109109
}
110110

111+
/// <summary>
112+
/// Adds a custom metadata repository implementation to the FIDO2 builder.
113+
/// </summary>
114+
/// <typeparam name="T">The type of metadata repository to add. Must implement <see cref="IMetadataRepository"/>.</typeparam>
115+
/// <param name="builder">The FIDO2 builder instance.</param>
116+
/// <returns>The <see cref="IFido2NetLibBuilder"/> for method chaining.</returns>
117+
/// <remarks>
118+
/// This method registers the specified metadata repository implementation as a scoped service,
119+
/// replacing any previously registered <see cref="IMetadataRepository"/>.
120+
/// The repository provides metadata statements for authenticator validation and attestation verification.
121+
/// </remarks>
122+
/// <exception cref="ArgumentNullException">Thrown when <paramref name="builder"/> is null.</exception>
123+
public static IFido2NetLibBuilder AddMetadataRepository<T>(this IFido2NetLibBuilder builder)
124+
where T : class, IMetadataRepository
125+
{
126+
builder.Services.AddScoped<IMetadataRepository, T>();
127+
return builder;
128+
}
129+
111130
/// <summary>
112131
/// Adds a file system-based metadata repository to the FIDO2 builder.
113132
/// </summary>

0 commit comments

Comments
 (0)