Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            IdentityModelEventSource.ShowPII = true;


            services.Configure <CookiePolicyOptions>(options => {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddAuthentication(options => {
                options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultSignInScheme       = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = CookieAuthenticationDefaults.AuthenticationScheme;
            })
            .AddCookie()
            .AddAuth0OpenIdConnect(Configuration);

            services.AddAuthorization(config => {
                config.AddPolicy(nameof(Policy.GlobalAdmin), p => {
                    p.RequireRole("GlobalAdmin");
                });
            });


            services.AddMvc()
            .AddNewtonsoftJson();

            services.AddHttpContextAccessor();
            services.AddScoped <ClaimsPrincipal>(context => context.GetRequiredService <IHttpContextAccessor>()?.HttpContext?.User);

            services.AddControllers();

            services.AddServerSideBlazor();
            services.AddSignalR(config => {
                config.EnableDetailedErrors = true;
            }).AddJsonProtocol();

            services.Configure <BotConfiguration>(Configuration.GetSection("BotConfig"));

            services.AddSingleton <ActorSystem>(_ => ActorSystem.Create("BotService"));

            services.AddTransient <IChannelConfigurationContext, FileStorageChannelConfigurationContext>();

            services.AddHttpClient("TwitchHelixApi", config => {
                config.BaseAddress = new Uri(Configuration["TwitchAPI:EndpointURL"]);
                config.DefaultRequestHeaders.Add("Accept", @"application/json");
                config.DefaultRequestHeaders.Add("Authorization", $"Bearer {Configuration["BotConfig:Password"]}");
            });

            // Cheer 100 ramblinggeek 19/4/19

            services.AddSingleton <IActorRef>(provider => ChannelManagerActor.Create(
                                                  provider.GetService <ActorSystem>(),
                                                  provider
                                                  ));
        }
Пример #2
0
        public static IServiceCollection ConfigureActorModel(this IServiceCollection services)
        {
            services.AddSingleton <ActorSystem>(_ => ActorSystem.Create("BotService"));

            services.AddSingleton <IActorRef>(provider => ChannelManagerActor.Create(
                                                  provider.GetService <ActorSystem>(),
                                                  provider
                                                  ));

            return(services);
        }
Пример #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options => {
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddAuthentication(options => {
                options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultSignInScheme       = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = CookieAuthenticationDefaults.AuthenticationScheme;
            })
            .AddCookie()
            .AddAuth0OpenIdConnect(Configuration);

            services.AddAuthorization(config => {
                config.AddPolicy(nameof(Policy.GlobalAdmin), p => {
                    p.RequireRole("GlobalAdmin");
                });
            });

            services.AddMvc()
            .AddNewtonsoftJson();

            services.AddHttpContextAccessor();
            services.AddScoped <ClaimsPrincipal>(context => context.GetRequiredService <IHttpContextAccessor>()?.HttpContext?.User);

            services.AddControllers();

            services.AddServerSideBlazor();
            services.AddSignalR(config => {
                config.EnableDetailedErrors = true;
            }).AddJsonProtocol();


            services.Configure <BotConfiguration>(Configuration.GetSection("BotConfig"));

            services.AddSingleton <ActorSystem>(_ => ActorSystem.Create("BotService"));

            services.AddTransient <IChannelConfigurationContext, ChannelConfigurationContext>();

            // Cheer 100 ramblinggeek 19/4/19

            services.AddSingleton <IActorRef>(provider => ChannelManagerActor.Create(
                                                  provider.GetService <ActorSystem>(),
                                                  provider.GetService <IChannelConfigurationContext>(),
                                                  provider.GetService <IHubContext <LoggerHub, IChatLogger> >()
                                                  ));
        }