Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                IdentityModelEventSource.ShowPII = true; //capturar erros PII (expiração token)
            }



            CorsSetup.UseCorsSetup(app);//deve ficar aqui esta linha

            app.UseHttpsRedirection();

            app.UseRouting();

            //app.UseAuthorization();--antiga autorização para swagger(deve ser retirada para o JWT funcionar)

            //setup para configuração do JWT bearer..
            JwtBearerSetup.UseJwtBearerSetup(app);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            //setup para configuração do Swagger..
            SwaggerSetup.UseSwaggerSetup(app);
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            //Setup para configuração do Swagger
            SwaggerSetup.AddSwaggerSetup(services);

            //Setup para configuração do EF
            EntityFrameworkSetup.AddEntityFrameworkSetup(services, Configuration);

            //Setup para o JWT
            JwtBearerSetup.AddJwtBearerSetup(services, Configuration);

            //Setup para MongoDB
            MongoDbSetup.AddMongoDbSetup(services, Configuration);

            //Injecao de dependencia
            DependenxyInjection.Register(services);

            //Setup para MediatR
            MediatRSetup.AddMediatRSetup(services);

            //Setup para AutoMapper
            AutoMapperSetup.AddAutoMapperSetup(services);

            //Setup para o CORS
            CorsSetup.AddCorsSetup(services);
        }
Exemple #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Run inversion of control.
            IocSetup.Run(services, Configuration);

            // Run authentication setup.
            AuthenticationSetup.Run(services, Configuration);

            // Add CORS support.
            CorsSetup.Run(services, Configuration);

            // Add http context accessor.
            services.AddHttpContextAccessor();

            // Add app db context.
            AppDbContextSetup.Run(services, Configuration);

            //// some details omitted
            //services.AddIdentityServer()
            //    .AddInMemoryApiResources(Is4Setup.LoadApiResources())
            //    .AddInMemoryIdentityResources(Is4Setup.LoadIdentityResources())
            //    .AddInMemoryClients(Is4Setup.LoadClients())
            //    .AddDeveloperSigningCredential();

            //services.AddAuthentication()
            //    .AddGoogle("Google", options =>
            //    {
            //        options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;

            //        options.ClientId = "323676358406-ikvol20relacv3mn5popdi79e5m759pc.apps.googleusercontent.com";
            //        options.ClientSecret = "68pGK3guMhv_bdJKQOznblSi";
            //    })
            //    .AddOpenIdConnect("demoidsrv", "IdentityServer", options =>
            //    {
            //        options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
            //        options.SignOutScheme = IdentityServerConstants.SignoutScheme;

            //        options.Authority = "http://localhost:57547";
            //        options.ClientId = "implicit";
            //        options.ResponseType = "id_token";
            //        options.SaveTokens = true;
            //        options.CallbackPath = new PathString("/signin-idsrv");
            //        options.SignedOutCallbackPath = new PathString("/signout-callback-idsrv");
            //        options.RemoteSignOutPath = new PathString("/signout-idsrv");
            //        options.RequireHttpsMetadata = false;

            //        options.TokenValidationParameters = new TokenValidationParameters
            //        {
            //            NameClaimType = "name",
            //            RoleClaimType = "role"
            //        };
            //    });

            services
            .AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Exemple #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            EntityFrameworkSetup.AddEntityFrameworkSetup(services, Configuration);

            DependencyInjection.Register(services);

            AutoMapperSetup.AddAutoMapperSetup(services);

            CorsSetup.AddCorsSetup(services);

            SwaggerSetup.AddSwaggerSetup(services);
        }
Exemple #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            SwaggerSetup.ConfigureServices(services);

            CorsSetup.ConfigureServices(services);

            EntityFrameWorkSetup.ConfigurationServices(services, Configuration);

            DependencyInjectionSetup.ConfigureServices(services);

            JWTSetup.ConfigureServices(services, Configuration);

            AutoMapperSetup.ConfigureServices(services);
        }
Exemple #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            CorsSetup.UseCorsSetup(app);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            SwaggerSetup.UseSwaggerSetup(app);
        }
Exemple #7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            //Configuração do Swagger
            SwaggerSetup.ConfigureServices(services);

            //Configuração do CORS
            CorsSetup.ConfigureServices(services);

            //Configuração do EntityFramework
            EntityFrameworkSetup.ConfigureServices(services, Configuration);

            //Configuração de Injeção de Dependência
            DependencyInjectionSetup.ConfigureServices(services);

            //Configuração do AutoMapper
            AutoMapperSetup.ConfigureServices(services);
        }
Exemple #8
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllers();
     //setup para configuração Swagger..
     SwaggerSetup.AddSwaggerSetup(services);
     //setup para configuração do EntityFramework..
     EntityFrameworkSetup.AddEntityFrameworkSetup(services, Configuration);
     //setup para configuração de injeção de dependencia..
     InjecaoDependencia.Registrar(services);
     //setup para JWT Bearer..
     JwtBearerSetup.AddJwtBearerSetup(services, Configuration);
     //setup para MongoDB..
     MongoDBSetup.AddMongoDBSetup(services, Configuration);
     //setup para MediatR..
     MediatRSetup.AddMediatRSetup(services);
     //setup para AutoMapper..
     AutoMapperSetup.AddAutoMapperSetup(services);
     //Setup para o Cors
     CorsSetup.AddCorsSetup(services);
 }
Exemple #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //Configuração do Swagger
            SwaggerSetup.Configure(app);

            //Configuração do CORS
            CorsSetup.Configure(app);

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }