Ejemplo n.º 1
0
        public Startup(IApplicationEnvironment appEnv, IHostingEnvironment hostingEnv, Microsoft.Framework.Logging.ILoggerFactory loggerFactory)
        {
            var serilogLogger = new LoggerConfiguration()
                                .WriteTo.TextWriter(Console.Out)
                                .MinimumLevel.Verbose()
                                .CreateLogger();

            var config = new ConfigurationBuilder()
                         .SetBasePath(appEnv.ApplicationBasePath)
                         .AddJsonFile("config.json")
                         .AddEnvironmentVariables("ModernShoppingAuthSampleApp_")
                         .Build();

            Log.Logger = serilogLogger;
            loggerFactory.MinimumLevel = LogLevel.Debug;
            loggerFactory.AddSerilog(serilogLogger);

            _appEnv        = appEnv;
            _hostingEnv    = hostingEnv;
            _logger        = new Logger <Startup>(loggerFactory);
            _configuration = config;
        }
Ejemplo n.º 2
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory, IApplicationLifetime lifetime, IBusManager busManager)
        {
            loggerfactory.AddSerilog();

            Log.Information("Configuring the Application");

            app.UseCors(_aureliaAppPolicyName);

            var options = new IdentityServerBearerTokenAuthenticationOptions
            {
                Authority      = _appSettings.IdentityServerAuthority,
                RequiredScopes = new[] { _appSettings.IdentityServerSettings.ClientId },
                NameClaimType  = "preferred_username"
            };

            app.UseAppBuilder(
                builder =>
            {
                builder.SetLoggerFactory(LoggerFactory.Default);
                builder.UseIdentityServerBearerTokenAuthentication(options);
            },
                _appSettings.ServiceSettings.ServiceName);

            app.UseMiddleware <ContextMiddleware>();
            app.UseMvc();

            Log.Information("Getting ready to start the bus manager");

            busManager.Start(
                new[] { typeof(StartApplication).Assembly, Assembly.GetExecutingAssembly() },
                config => config.RegisterComponents(r => r.ConfigureComponent <OutgoingAppContextMutator>(DependencyLifecycle.InstancePerUnitOfWork)));

            lifetime.ApplicationStopping.Register(busManager.Stop);

            _loggingLevelSwitch.MinimumLevel = LogEventLevel.Information;
        }
Ejemplo n.º 3
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory, IApplicationLifetime lifetime, IBusManager busManager)
        {
            loggerfactory.AddSerilog();

            Log.Information("Configuring the Application");

            app.UseCors(_aureliaAppPolicyName);

            var options = new IdentityServerBearerTokenAuthenticationOptions
            {
                Authority = _appSettings.IdentityServerAuthority,
                RequiredScopes = new[] { _appSettings.IdentityServerSettings.ClientId },
                NameClaimType = "preferred_username"
            };

            app.UseAppBuilder(
                builder =>
                {
                    builder.SetLoggerFactory(LoggerFactory.Default);
                    builder.UseIdentityServerBearerTokenAuthentication(options);
                },
                _appSettings.ServiceSettings.ServiceName);

            app.UseMiddleware<ContextMiddleware>();
            app.UseMvc();

            Log.Information("Getting ready to start the bus manager");

            busManager.Start(
                new[] { typeof(StartApplication).Assembly, Assembly.GetExecutingAssembly() },
                config => config.RegisterComponents(r => r.ConfigureComponent<OutgoingAppContextMutator>(DependencyLifecycle.InstancePerUnitOfWork)));

            lifetime.ApplicationStopping.Register(busManager.Stop);

            _loggingLevelSwitch.MinimumLevel = LogEventLevel.Information;
        }