@@ -14,26 +14,29 @@ namespace Microsoft.Extensions.DependencyInjection;
1414
1515public static class JwtBuilderExtensions
1616{
17- public static IJwksBuilder UseNetDevPackIdentity < TIdentityUser , TKey > ( this IServiceCollection services ) where TIdentityUser : IdentityUser < TKey > where TKey : IEquatable < TKey >
17+ public static IJwksBuilder AddNetDevPackIdentity < TIdentityUser , TKey > ( this IServiceCollection services ) where TIdentityUser : IdentityUser < TKey > where TKey : IEquatable < TKey >
1818 {
19- services . TryAddScoped < IJwtBuilder , JwtBuilderInject < TIdentityUser , TKey > > ( ) ;
19+ services . AddDataProtection ( ) ;
20+ services . AddScoped < IJwtBuilder , JwtBuilderInject < TIdentityUser , TKey > > ( ) ;
2021 return services . AddHttpContextAccessor ( ) . AddJwksManager ( ) ;
2122 }
22- public static IJwksBuilder UseNetDevPackIdentity < TIdentityUser > ( this IServiceCollection services ) where TIdentityUser : IdentityUser
23+ public static IJwksBuilder AddNetDevPackIdentity < TIdentityUser > ( this IServiceCollection services ) where TIdentityUser : IdentityUser
2324 {
24- services . TryAddScoped < IJwtBuilder , JwtBuilderInject < TIdentityUser , string > > ( ) ;
25+ services . AddDataProtection ( ) ;
26+ services . AddScoped < IJwtBuilder , JwtBuilderInject < TIdentityUser , string > > ( ) ;
2527 return services . AddHttpContextAccessor ( ) . AddJwksManager ( ) ;
2628 }
27- public static IJwksBuilder UseNetDevPackIdentity ( this IServiceCollection services )
29+ public static IJwksBuilder AddNetDevPackIdentity ( this IServiceCollection services )
2830 {
29- services . TryAddScoped < IJwtBuilder , JwtBuilderInject < IdentityUser , string > > ( ) ;
31+ services . AddDataProtection ( ) ;
32+ services . AddScoped < IJwtBuilder , JwtBuilderInject < IdentityUser , string > > ( ) ;
3033 return services . AddHttpContextAccessor ( ) . AddJwksManager ( ) ;
3134 }
32-
35+
3336 public static IdentityBuilder AddIdentityConfiguration ( this IServiceCollection services )
3437 {
3538 if ( services == null ) throw new ArgumentException ( nameof ( services ) ) ;
36- services . UseNetDevPackIdentity ( ) ;
39+ services . AddNetDevPackIdentity ( ) ;
3740
3841 return services . AddIdentityCore < IdentityUser > ( )
3942 . AddRoles < IdentityRole > ( )
@@ -44,7 +47,7 @@ public static IdentityBuilder AddIdentityConfiguration(this IServiceCollection s
4447 public static IdentityBuilder AddDefaultIdentity ( this IServiceCollection services , Action < IdentityOptions > options = null )
4548 {
4649 if ( services == null ) throw new ArgumentException ( nameof ( services ) ) ;
47- services . UseNetDevPackIdentity < IdentityUser > ( ) ;
50+ services . AddNetDevPackIdentity < IdentityUser > ( ) ;
4851 return services . AddIdentityCore < IdentityUser > ( options )
4952 . AddDefaultTokenProviders ( ) ;
5053 }
@@ -63,7 +66,7 @@ public static IdentityBuilder AddCustomIdentity<TIdentityUser, TKey>(this IServi
6366 where TKey : IEquatable < TKey >
6467 {
6568 if ( services == null ) throw new ArgumentException ( nameof ( services ) ) ;
66- services . UseNetDevPackIdentity < TIdentityUser , TKey > ( ) ;
69+ services . AddNetDevPackIdentity < TIdentityUser , TKey > ( ) ;
6770 return services . AddIdentityCore < TIdentityUser > ( options )
6871 . AddDefaultTokenProviders ( ) ;
6972 }
0 commit comments