@@ -12,31 +12,57 @@ namespace Microsoft.Extensions.DependencyInjection;
1212
1313public static class JwtBuilderExtensions
1414{
15- public static IJwksBuilder AddNetDevPackIdentity < TIdentityUser , TKey > ( this IServiceCollection services , Action < JwtOptions > options = null )
16- where TIdentityUser : IdentityUser < TKey > where TKey : IEquatable < TKey >
15+ public static IJwksBuilder AddNetDevPackIdentity < TIdentityUser , TKey > ( this IServiceCollection services , Action < JwtOptions > options = null )
16+ where TIdentityUser : IdentityUser < TKey >
17+ where TKey : IEquatable < TKey >
1718 {
18- services . AddDataProtection ( ) ;
19+ services . AddHttpContextAccessor ( ) ;
1920 services . AddScoped < IJwtBuilder , JwtBuilderInject < TIdentityUser , TKey > > ( ) ;
20- return services . AddHttpContextAccessor ( ) . AddJwksManager ( ) ;
21+ return services . AddJwksManager ( options ) ;
2122 }
22- public static IJwksBuilder AddNetDevPackIdentity < TIdentityUser > ( this IServiceCollection services , Action < JwtOptions > options = null )
23+
24+ public static IJwksBuilder AddNetDevPackIdentity < TIdentityUser > ( this IServiceCollection services , Action < JwtOptions > options = null )
2325 where TIdentityUser : IdentityUser
2426 {
25- services . AddDataProtection ( ) ;
27+ services . AddHttpContextAccessor ( ) ;
2628 services . AddScoped < IJwtBuilder , JwtBuilderInject < TIdentityUser , string > > ( ) ;
27- return services . AddHttpContextAccessor ( ) . AddJwksManager ( ) ;
29+ return services . AddJwksManager ( options ) ;
2830 }
31+
2932 public static IJwksBuilder AddNetDevPackIdentity ( this IServiceCollection services , Action < JwtOptions > options = null )
3033 {
31- services . AddDataProtection ( ) ;
34+ services . AddHttpContextAccessor ( ) ;
3235 services . AddScoped < IJwtBuilder , JwtBuilderInject < IdentityUser , string > > ( ) ;
33- return services . AddHttpContextAccessor ( ) . AddJwksManager ( options ) ;
36+ return services . AddJwksManager ( options ) ;
37+ }
38+
39+ public static IJwksBuilder AddNetDevPackIdentity < TIdentityUser , TKey > ( this IJwksBuilder services )
40+ where TIdentityUser : IdentityUser < TKey >
41+ where TKey : IEquatable < TKey >
42+ {
43+ services . Services . AddHttpContextAccessor ( ) ;
44+ services . Services . AddScoped < IJwtBuilder , JwtBuilderInject < TIdentityUser , TKey > > ( ) ;
45+ return services ;
46+ }
47+
48+ public static IJwksBuilder AddNetDevPackIdentity < TIdentityUser > ( this IJwksBuilder services )
49+ where TIdentityUser : IdentityUser
50+ {
51+ services . Services . AddHttpContextAccessor ( ) ;
52+ services . Services . AddScoped < IJwtBuilder , JwtBuilderInject < TIdentityUser , string > > ( ) ;
53+ return services ;
54+ }
55+
56+ public static IJwksBuilder AddNetDevPackIdentity ( this IJwksBuilder services )
57+ {
58+ services . Services . AddHttpContextAccessor ( ) ;
59+ services . Services . AddScoped < IJwtBuilder , JwtBuilderInject < IdentityUser , string > > ( ) ;
60+ return services ;
3461 }
3562
3663 public static IdentityBuilder AddIdentityConfiguration ( this IServiceCollection services )
3764 {
3865 if ( services == null ) throw new ArgumentException ( nameof ( services ) ) ;
39- services . AddNetDevPackIdentity ( ) ;
4066
4167 return services
4268 . AddIdentity < IdentityUser , IdentityRole > ( )
@@ -47,7 +73,6 @@ public static IdentityBuilder AddIdentityConfiguration(this IServiceCollection s
4773 public static IdentityBuilder AddDefaultIdentity ( this IServiceCollection services , Action < IdentityOptions > options = null )
4874 {
4975 if ( services == null ) throw new ArgumentException ( nameof ( services ) ) ;
50- services . AddNetDevPackIdentity < IdentityUser > ( ) ;
5176 return services
5277 . AddIdentity < IdentityUser , IdentityRole > ( )
5378 . AddDefaultTokenProviders ( ) ;
@@ -67,7 +92,6 @@ public static IdentityBuilder AddCustomIdentity<TIdentityUser, TKey>(this IServi
6792 where TKey : IEquatable < TKey >
6893 {
6994 if ( services == null ) throw new ArgumentException ( nameof ( services ) ) ;
70- services . AddNetDevPackIdentity < TIdentityUser , TKey > ( ) ;
7195 return services . AddIdentity < TIdentityUser , IdentityRole < TKey > > ( options )
7296 . AddDefaultTokenProviders ( ) ;
7397 }
0 commit comments