示例#1
0
 public static IJointBuilder AddApplication(this IJointBuilder builder)
 {
     return(builder
            .AddCommandHandlers()
            .AddEventHandlers()
            .AddInMemoryCommandDispatcher()
            .AddInMemoryEventDispatcher());
 }
示例#2
0
 public LineBuilder(IBezierBuilder b, IJointBuilder j, IJointBuilder js, ICapBuilder c, ISpline line)
 {
     _bezierDrawer         = b;
     _jointDrawer          = j;
     _capDrawer            = c;
     _line                 = line;
     _jointIntersectDrawer = js;
 }
示例#3
0
 public static IJointBuilder AddInfrastructure(this IJointBuilder builder)
 {
     return(builder
            .AddMongo()
            .AddMongoRepository <UserDocument, Guid>("users")
            .AddErrorHandler <ExceptionToResponseMapper>()
            .AddQueryHandlers()
            .AddInMemoryQueryDispatcher());
 }
示例#4
0
        public static IJointBuilder AddOcelot(this IJointBuilder builder, string sectionName = SectionRoutesName)
        {
            var optionsRoutes = builder.GetOptions <AnonymousRoutesOptions>(sectionName);
            var optionsOcelot = builder.GetOptions <OcelotOptions>(SectionOcelotName);

            builder.Services.AddSingleton(optionsRoutes);
            builder.Services.AddSingleton(optionsOcelot);
            builder.Services.AddSingleton <IAnonymousRouteValidator, AnonymousRouteValidator>();
            builder.Services.AddOcelot();

            return(builder);
        }
示例#5
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));
        }
示例#6
0
        private static IJointBuilder AddJwt(this IJointBuilder builder, JwtOptions options,
                                            Action <JwtBearerOptions> optionsFactory = null)
        {
            if (!builder.TryRegister(RegistryName))
            {
                return(builder);
            }

            builder.Services.AddTransient <IJwtHandler, JwtHandler>();
            builder.Services.AddSingleton <IAccessTokenService, InMemoryAccessTokenService>();
            builder.Services.AddTransient <AccessTokenValidatorMiddleware>();

            var tokenValidationParameters = TokenValidationFactory.CreateParameters(options);

            tokenValidationParameters.AddIssuerSigningKey(options);
            tokenValidationParameters.AddAuthenticationType(options);
            tokenValidationParameters.AddNameClaimType(options);
            tokenValidationParameters.AddRoleClaimType(options);

            builder.Services
            .AddAuthentication(o =>
            {
                o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                o.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, option =>
            {
                option.Authority                  = options.Authority;
                option.Audience                   = options.ValidAudience;
                option.MetadataAddress            = options.MetadataAddress;
                option.SaveToken                  = options.SaveToken;
                option.RefreshOnIssuerKeyNotFound = options.RefreshOnIssuerKeyNotFound;
                option.RequireHttpsMetadata       = options.RequireHttpsMetadata;
                option.IncludeErrorDetails        = options.IncludeErrorDetails;
                option.TokenValidationParameters  = tokenValidationParameters;
                if (!string.IsNullOrWhiteSpace(options.Challenge))
                {
                    option.Challenge = options.Challenge;
                }

                optionsFactory?.Invoke(option);
            });

            builder.Services.AddSingleton(options);
            builder.Services.AddSingleton(tokenValidationParameters);

            return(builder);
        }
        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());
        }