Esempio n. 1
0
        public static IJointBuilder AddJwt(this IJointBuilder builder, string sectionName = SectionName,
                                           Action <JwtBearerOptions> optionsFactory       = null)
        {
            if (string.IsNullOrWhiteSpace(sectionName))
            {
                sectionName = SectionName;
            }

            var options = builder.GetOptions <JwtOptions>(sectionName);

            return(builder.AddJwt(options, optionsFactory));
        }
        public static IJointBuilder AddInfrastructure(this IJointBuilder builder)
        {
            builder.Services.AddTransient <ICookieFactory, CookieFactory>();
            builder.Services.AddTransient <IJwtProvider, JwtProvider>();
            builder.Services.AddTransient <IPasswordService, PasswordService>();
            builder.Services.AddSingleton <IPasswordHasher <IPasswordService>, PasswordHasher <IPasswordService> >();
            builder.Services.AddTransient <IRng, Rng>();
            builder.Services.AddTransient <IRefreshTokenRepository, RefreshTokenRepository>();
            builder.Services.AddTransient <IUserRepository, UserRepository>();
            builder.Services.AddTransient <IIdentityService, IdentityService>();
            builder.Services.AddTransient <IRefreshTokenService, RefreshTokenService>();
            builder.Services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            return(builder
                   .AddJwt()
                   .AddMongo()
                   .AddMongoRepository <UserDocument, Guid>("users")
                   .AddMongoRepository <RefreshTokenDocument, Guid>("refreshTokens")
                   .AddRedis()
                   .AddConsul()
                   .AddErrorHandler <ExceptionToResponseMapper>()
                   .AddQueryHandlers()
                   .AddInMemoryQueryDispatcher());
        }