Exemplo n.º 1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     ConfigureService.ConfigureDependenciesService(services);
     ConfigureRepository.ConfigureDependenciesRepository(services);
     services.AddControllers();
     services.AddSwaggerGen(c =>
     {
         c.SwaggerDoc("v1", new OpenApiInfo
         {
             Version        = "v1",
             Title          = "Api",
             Description    = "Arquitura DDD",
             TermsOfService = new Uri("http://www.ivanlg.epizy.com"),//não esta pronto o portifólio!
             Contact        = new OpenApiContact
             {
                 Name  = "Ivan Luiz Gessi",
                 Email = "*****@*****.**",
                 Url   = new Uri("http://www.ivanlg.epizy.com")
             },
             License = new OpenApiLicense
             {
                 Name = "Termo de Licença de Uso",
                 Url  = new Uri("http://www.ivanlg.epizy.com")
             }
         });
     });
 }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);
            services.AddCors(o =>
            {
                o.AddDefaultPolicy(
                    b =>
                {
                    b.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
                }
                    );
            });
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Loja Virutal",
                    Version     = "v1",
                    Description = "Api para loja virtual usando arquitetura DDD e TDD",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Jonathan Vegas Peixoto",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://jonathanvegas.tech")
                    }
                }

                             );
            });
        }
Exemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "Wevo API",
                    Description = "Desafio",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Kako",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://github.com/KakoF")
                    }
                });
            });
        }
Exemplo n.º 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfiguracaoTesteIntegracao();

            services.AddControllers();

            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);
            ConfigureHelper.ConfigureDependenciesHelper(services);

            services.AddSingleton(ConfigurationMapper());

            SigningConfigurations signingConfigurations = new SigningConfigurations();

            services.AddSingleton(signingConfigurations);

            TokenConfigurations tokenConfigurations = BuilderTokenConfigurations();

            services.AddAuthentication(ConfigurationAddAuthentication()).AddJwtBearer(ConfigurationAddJwtBearer(signingConfigurations, tokenConfigurations));

            // Ativa o uso do token como forma de autorizar o acesso
            // a recursos deste projeto
            services.AddAuthorization(ConfigurationAddAuthorization());

            services.AddSingleton(tokenConfigurations);

            services.AddSwaggerGen(c => ConfigurationSwagger(c));
        }
Exemplo n.º 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new OpenApiInfo
                {
                    Title       = "MANAGER OPEN ERP",
                    Version     = "v1",
                    Description = "API REST criada com o ASP.NET Core para Gestão de OPEN ERP",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Apeninos.COM",
                        Email = string.Empty,
                        Url   = new Uri("https://apeninos.com/")
                    }
                });


                // Set the comments path for the Swagger JSON and UI.
            });

            services.AddControllers();
        }
Exemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version = "v1",
                    Title   = "API AspNetCore"
                });
            }
                                   );
        }
Exemplo n.º 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();

            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "Api Restaurant App",
                    Description = "Api of Restaurant Application",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Matheus de Almeida Oliveira",
                        Email = "*****@*****.**"
                    }
                });
            });

            services.AddCors(options =>
            {
                options.AddPolicy("EnableCORS", builder =>
                {
                    builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().Build();
                });
            });
        }
Exemplo n.º 8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);

            ConfigureRepository.ConfigureDependenciesRepository(services);

            services.AddControllersWithViews();
        }
Exemplo n.º 9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services); //adicionado configuracao statica do automapper
            ConfigureRepository.ConfigureDependenciesRepository(services);

            #region Configuracao AutoMapper
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            #endregion
            #region Configuracao Jwt
            var signingConfigurations = new SigningConfigurations();
            services.AddSingleton(signingConfigurations);

            var tokenConfigurations = new TokenConfigurations();
            new ConfigureFromConfigurationOptions <TokenConfigurations>(
                Configuration.GetSection("TokenConfigurations"))
            .Configure(tokenConfigurations);
            services.AddSingleton(tokenConfigurations);
            #endregion

            #region Autenticaçao
            services.AddAuthentication(authOptions =>
            {
                authOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                authOptions.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(bearerOptions =>
            {
                var paramsValidation = bearerOptions.TokenValidationParameters;
                paramsValidation.IssuerSigningKey         = signingConfigurations.Key;
                paramsValidation.ValidAudience            = tokenConfigurations.Audience;
                paramsValidation.ValidIssuer              = tokenConfigurations.Issuer;
                paramsValidation.ValidateIssuerSigningKey = true;
                paramsValidation.ValidateLifetime         = true;
                paramsValidation.ClockSkew = TimeSpan.Zero;
            });

            services.AddAuthorization(auth =>
            {
                auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
                               .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
                               .RequireAuthenticatedUser().Build());
            });

            #endregion

            services.AddControllersWithViews();
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            var signingConfiguration = new SigningConfiguration();

            services.AddSingleton(signingConfiguration);

            var tokenConfiguration = new TokenConfiguration();

            new ConfigureFromConfigurationOptions <TokenConfiguration>(
                Configuration.GetSection("TokenConfigurations"))
            .Configure(tokenConfiguration);
            services.AddSingleton(tokenConfiguration);

            services.AddAuthentication(authOptions =>
            {
                authOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                authOptions.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(bearerOptions =>
            {
                var paramsValidation = bearerOptions.TokenValidationParameters;
                paramsValidation.IssuerSigningKey         = signingConfiguration.Key;
                paramsValidation.ValidAudience            = tokenConfiguration.Audience;
                paramsValidation.ValidIssuer              = tokenConfiguration.Issuer;
                paramsValidation.ValidateIssuerSigningKey = true;
                paramsValidation.ValidateLifetime         = true;
                paramsValidation.ClockSkew = TimeSpan.Zero;
            });

            services.AddAuthorization(auth =>
            {
                auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
                               .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
                               .RequireAuthenticatedUser().Build());
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new Info
                {
                    Title       = "API AspNetCore 2.2",
                    Version     = "v1",
                    Description = "Nova API utilizando AspNetCore 2.2",
                    Contact     = new Contact
                    {
                        Name = "Tiago Gilli",
                        Url  = "https://github.com/tiagogilli99/API-ApsNetCore-2.2"
                    }
                });
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Exemplo n.º 11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);


            var signingConfigurations = new SigningConfigurations();

            services.AddSingleton(signingConfigurations);

            var tokenConfigurations = new TokenConfigurations();

            new ConfigureFromConfigurationOptions <TokenConfigurations>(
                Configuration.GetSection("TokenConfigurations"))
            .Configure(tokenConfigurations);
            services.AddSingleton(tokenConfigurations);

            services.AddAuthentication(authOptions =>
            {
                authOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                authOptions.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(bearerOptions =>
            {
                var parmsValidation = bearerOptions.TokenValidationParameters;
                parmsValidation.IssuerSigningKey = signingConfigurations.Key;
                parmsValidation.ValidAudience    = tokenConfigurations.Audience;
                parmsValidation.ValidIssuer      = tokenConfigurations.Issuer;
                parmsValidation.ValidateLifetime = true;
                parmsValidation.ClockSkew        = TimeSpan.Zero;
            });

            services.AddAuthorization(auth =>
            {
                auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
                               .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
                               .RequireAuthenticatedUser().Build());
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new Info
                {
                    Title       = "Curso de AspNetCore 2.2",
                    Version     = "v1",
                    Description = "Exemplo de API REST criada com o ASP.NET Core",
                    Contact     = new Contact
                    {
                        Name = "Demerson Costa Ferreira",
                        Url  = "https://github.com/mfrinfo"
                    }
                });
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Exemplo n.º 12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy("CorsPolicy",
                                  builder =>
                {
                    builder
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .WithOrigins(
                        "http://*****:*****@hotmail.com"
                    }
                });
                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = System.IO.Path.Combine(AppContext.BaseDirectory, xmlFile);
                x.IncludeXmlComments(xmlPath);
            });
        }