@@ -16,16 +16,10 @@ public static IFido2NetLibBuilder AddFido2(this IServiceCollection services, ICo
16
16
services . AddSingleton (
17
17
resolver => resolver . GetRequiredService < IOptions < Fido2Configuration > > ( ) . Value ) ;
18
18
19
- services . AddServices ( ) ;
20
-
21
- return new Fido2NetLibBuilder ( services ) ;
22
- }
23
-
24
- private static void AddServices ( this IServiceCollection services )
25
- {
26
19
services . AddScoped < IFido2 , Fido2 > ( ) ;
27
- services . AddSingleton < IMetadataService , NullMetadataService > ( ) ; //Default implementation if we choose not to enable MDS
28
20
services . TryAddSingleton < ISystemClock , SystemClock > ( ) ;
21
+
22
+ return new Fido2NetLibBuilder ( services ) ;
29
23
}
30
24
31
25
public static IFido2NetLibBuilder AddFido2 ( this IServiceCollection services , Action < Fido2Configuration > setupAction )
@@ -35,19 +29,27 @@ public static IFido2NetLibBuilder AddFido2(this IServiceCollection services, Act
35
29
services . AddSingleton (
36
30
resolver => resolver . GetRequiredService < IOptions < Fido2Configuration > > ( ) . Value ) ;
37
31
38
- services . AddServices ( ) ;
32
+ services . AddScoped < IFido2 , Fido2 > ( ) ;
33
+ services . TryAddSingleton < ISystemClock , SystemClock > ( ) ;
39
34
40
35
return new Fido2NetLibBuilder ( services ) ;
41
36
}
42
-
43
- public static void AddCachedMetadataService ( this IFido2NetLibBuilder builder , Action < IFido2MetadataServiceBuilder > configAction )
37
+
38
+ public static IFido2NetLibBuilder AddMetadataService < T > ( this IFido2NetLibBuilder builder )
39
+ where T : class , IMetadataService
40
+ {
41
+ builder . Services . AddScoped < IMetadataService , T > ( ) ;
42
+ return builder ;
43
+ }
44
+
45
+
46
+ public static IFido2NetLibBuilder AddCachedMetadataService ( this IFido2NetLibBuilder builder )
44
47
{
45
48
builder . Services . AddScoped < IMetadataService , DistributedCacheMetadataService > ( ) ;
46
-
47
- configAction ( new Fido2NetLibBuilder ( builder . Services ) ) ;
49
+ return builder ;
48
50
}
49
51
50
- public static IFido2MetadataServiceBuilder AddFileSystemMetadataRepository ( this IFido2MetadataServiceBuilder builder , string directoryPath )
52
+ public static IFido2NetLibBuilder AddFileSystemMetadataRepository ( this IFido2NetLibBuilder builder , string directoryPath )
51
53
{
52
54
builder . Services . AddScoped < IMetadataRepository , FileSystemMetadataRepository > ( provider =>
53
55
{
@@ -57,8 +59,8 @@ public static IFido2MetadataServiceBuilder AddFileSystemMetadataRepository(this
57
59
return builder ;
58
60
}
59
61
60
- public static IFido2MetadataServiceBuilder AddConformanceMetadataRepository (
61
- this IFido2MetadataServiceBuilder builder ,
62
+ public static IFido2NetLibBuilder AddConformanceMetadataRepository (
63
+ this IFido2NetLibBuilder builder ,
62
64
HttpClient client = null ,
63
65
string origin = "" )
64
66
{
@@ -70,7 +72,7 @@ public static IFido2MetadataServiceBuilder AddConformanceMetadataRepository(
70
72
return builder ;
71
73
}
72
74
73
- public static IFido2MetadataServiceBuilder AddFidoMetadataRepository ( this IFido2MetadataServiceBuilder builder , Action < IHttpClientBuilder > clientBuilder = null )
75
+ public static IFido2NetLibBuilder AddFidoMetadataRepository ( this IFido2NetLibBuilder builder , Action < IHttpClientBuilder > clientBuilder = null )
74
76
{
75
77
var httpClientBuilder = builder . Services . AddHttpClient ( nameof ( Fido2MetadataServiceRepository ) , client =>
76
78
{
@@ -91,12 +93,7 @@ public interface IFido2NetLibBuilder
91
93
IServiceCollection Services { get ; }
92
94
}
93
95
94
- public interface IFido2MetadataServiceBuilder
95
- {
96
- IServiceCollection Services { get ; }
97
- }
98
-
99
- public class Fido2NetLibBuilder : IFido2NetLibBuilder , IFido2MetadataServiceBuilder
96
+ public class Fido2NetLibBuilder : IFido2NetLibBuilder
100
97
{
101
98
/// <summary>
102
99
/// Initializes a new instance of the <see cref="Fido2NetLibBuilder"/> class.
0 commit comments