コード例 #1
0
ファイル: Startup.cs プロジェクト: chomiczkowy/HavingFun
        private static void SetUpRabbitMq(IServiceCollection services, MainApiSettings appSettings)
        {
            var rabbitServerUri = new Uri(appSettings.RabbitMq.HostUrl);

            services.AddMassTransit((cfg) =>
            {
                cfg.AddBus(isp =>
                {
                    var bus = Bus.Factory.CreateUsingRabbitMq(busCfg =>
                    {
                        busCfg.Host(new Uri(appSettings.RabbitMq.HostUrl), host =>
                        {
                            host.Username(appSettings.RabbitMq.Username);
                            host.Password(appSettings.RabbitMq.Password);
                        });

                        //busCfg.Message<UserCreatedMessage>(x =>
                        //{

                        //});
                    });

                    bus.Start();
                    return(bus);
                });
            });
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: chomiczkowy/HavingFun
        private static void SetUpJWT(IServiceCollection services, MainApiSettings appSettings)
        {
            var key = Encoding.ASCII.GetBytes(appSettings.JWTSecret);

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });
        }