Exemple #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            var cns =
                Configuration
                .GetSection("ConfigConnectionString:Default").Value;


            services.AddIdentityServer()
            .AddSigningCredential(GetRSAParameters())
            .AddInMemoryApiResources(Config.GetApiResources())
            .AddInMemoryIdentityResources(Config.GetIdentityResources())
            .AddInMemoryClients(Config.GetClients(Configuration.GetSection("ConfigSettings").Get <ConfigSettingsBase>()));

            //for clarity of the next piece of code
            services.AddScoped <CurrentUser>();
            services.AddTransient <IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);

            services.AddAuthentication()
            .AddGoogle(options =>
            {
                options.ClientId     = "857854978384-sv33ngtei50k8fn5ea37rcddo08n0ior.apps.googleusercontent.com";
                options.ClientSecret = "x1SWT89gyn5LLLyMNFxEx_Ss";
            });
            // Add cross-origin resource sharing services Configurations
            Cors.Enable(services);
            services.AddMvc();
        }
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.AddDbContext <DbContextCalemas.Erp>(
                options => options.UseSqlServer(
                    Configuration
                    .GetSection("EFCoreConnStrings:Calemas.Erp").Value));

            services.AddDistributedRedisCache(options =>
            {
                options.Configuration = Configuration.GetSection("RedisConnStrings:Calemas.Erp").Value;
                options.InstanceName  = "Calemas.Erp";
            });

            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);

            // Add cross-origin resource sharing services Configurations
            Cors.Enable(services);

            // Add application services.
            ConfigContainerCalemas.Erp.Config(services);

            // Add framework services.
            services.AddMvc();
        }
Exemple #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            var cns =
                Configuration
                .GetSection("EFCoreConnStrings:Target").Value;

            services.AddDbContext <DbContextTarget>(options => options.UseSqlServer(cns));

            //var migrationAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
            //services.AddDbContext<DbContextTarget>(options => options.UseSqlServer(cns));

            services.AddIdentityServer()
            .AddSigningCredential(GetRSAParameters())
            //.AddTemporarySigningCredential()
            .AddInMemoryApiResources(Config.GetApiResources())
            .AddInMemoryIdentityResources(Config.GetIdentityResources())
            .AddInMemoryClients(Config.GetClients(Configuration.GetSection("ConfigSettings").Get <ConfigSettingsBase>()));
            //.AddConfigurationStore(builder =>
            //        builder.UseSqlServer(cns, options =>
            //            options.MigrationsAssembly(migrationAssembly)))
            //    .AddOperationalStore(builder =>
            //        builder.UseSqlServer(cns, options =>
            //            options.MigrationsAssembly(migrationAssembly)));

            //for clarity of the next piece of code
            services.AddScoped <CurrentUser>();
            services.AddTransient <IUsuarioRepository, UsuarioRepository>();
            services.AddTransient <IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);

            //Add cross-origin resource sharing services Configurations
            Cors.Enable(services);
            services.AddMvc();
        }
        public void ConfigureServices(IServiceCollection services)
        {
            var cns =
                Configuration
                .GetSection("ConfigConnectionString:Default").Value;

            var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;

            services.AddIdentityServer()
            .AddSigningCredential(GetRSAParameters())
            //.AddInMemoryApiResources(Config.GetApiResources())
            //.AddInMemoryIdentityResources(Config.GetIdentityResources())
            //.AddInMemoryClients(Config.GetClients(Configuration.GetSection("ConfigSettings").Get<ConfigSettingsBase>()));
            .AddConfigurationStore(options =>
            {
                options.ConfigureDbContext = b =>
                                             b.UseSqlServer(cns, sql => sql.MigrationsAssembly(migrationsAssembly));
            }).AddOperationalStore(options => {
                options.ConfigureDbContext = b =>
                                             b.UseSqlServer(cns, sql => sql.MigrationsAssembly(migrationsAssembly));
            });

            //Configurations
            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.Configure <ConfigConnectionStringBase>(Configuration.GetSection("ConfigConnectionString"));
            //Container DI
            services.AddScoped <CurrentUser>();
            services.AddTransient <IUserCredentialServices, UserCredentialServices>();
            services.AddTransient <IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.AddConfiguration(Configuration.GetSection("Logging"));
                loggingBuilder.AddConsole();
                loggingBuilder.AddDebug();
            });

            services.AddAuthentication()
            .AddGoogle(options =>
            {
                options.ClientId     = "857854978384-sv33ngtei50k8fn5ea37rcddo08n0ior.apps.googleusercontent.com";
                options.ClientSecret = "x1SWT89gyn5LLLyMNFxEx_Ss";
            });
            // Add cross-origin resource sharing services Configurations
            var sp            = services.BuildServiceProvider();
            var configuration = sp.GetService <IOptions <ConfigSettingsBase> >();

            Cors.Enable(services, configuration.Value.ClientAuthorityEndPoint.ToArray());

            services.AddMvc();
        }
Exemple #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Camelcase para json
            services.AddMvc()
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
            });

            services.AddDbContext <DbContextSeed>(
                options => options.UseSqlServer(
                    Configuration
                    .GetSection("ConfigConnectionString:Default").Value));

            services.AddDistributedRedisCache(options =>
            {
                options.Configuration = Configuration.GetSection("RedisConnStrings:Seed").Value;
                options.InstanceName  = "Seed";
            });

            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddSingleton(new EnviromentInfo
            {
                RootPath = this._env.ContentRootPath
            });

            // Config AuthorityEndPoint SSO
            services.AddAuthentication("Bearer")
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority            = Configuration.GetSection("ConfigSettings:AuthorityEndPoint").Value;
                options.RequireHttpsMetadata = false;
                options.ApiName = "ssosa";
            });


            // Add cross-origin resource sharing services Configurations
            Cors.Enable(services);

            // Add application services.
            ConfigContainerSeed.Config(services);

            // Add framework services.
            services.AddMvc(options => { options.ModelBinderProviders.Insert(0, new DateTimePtBrModelBinderProvider()); })
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.Converters.Add(new DateTimePtBrConverter());
            });
        }
Exemple #6
0
        public void ConfigureServices(IServiceCollection services)
        {
            var cns =
                Configuration
                .GetSection("ConfigConnectionString:Default").Value;


            services.AddIdentityServer(optionsConfig())
            .AddSigningCredential(GetRSAParameters())
            .AddCustomTokenRequestValidator <ClientCredentialRequestValidator>()
            .AddInMemoryApiResources(Config.GetApiResources())
            .AddInMemoryIdentityResources(Config.GetIdentityResources())
            .AddInMemoryClients(Config.GetClients(Configuration.GetSection("ConfigSettings").Get <ConfigSettingsBase>()));

            //Configurations
            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.Configure <ConfigConnectionStringBase>(Configuration.GetSection("ConfigConnectionString"));
            //Container DI
            services.AddScoped <CurrentUser>();
            services.AddScoped <IUserCredentialServices, UserCredentialServices>();
            services.AddScoped <IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
            services.AddScoped <ICustomTokenRequestValidator, ClientCredentialRequestValidator>();
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.AddConfiguration(Configuration.GetSection("Logging"));
                loggingBuilder.AddConsole();
                loggingBuilder.AddDebug();
            });

            services.AddAuthentication()
            .AddGoogle(options =>
            {
                options.ClientId     = "857854978384-sv33ngtei50k8fn5ea37rcddo08n0ior.apps.googleusercontent.com";
                options.ClientSecret = "x1SWT89gyn5LLLyMNFxEx_Ss";
            });
            // Add cross-origin resource sharing services Configurations
            var sp            = services.BuildServiceProvider();
            var configuration = sp.GetService <IOptions <ConfigSettingsBase> >();

            Cors.Enable(services, configuration.Value.ClientAuthorityEndPoint.ToArray());

            services.AddMvc();
        }
Exemple #7
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <DbContextCore>(options => options.UseSqlServer(Configuration.GetSection("EFCoreConnStrings:Core").Value));

            services.AddDistributedRedisCache(options =>
            {
                options.Configuration = Configuration.GetSection("RedisConnStrings:Core").Value;
                options.InstanceName  = "Core";
            });

            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);

            Cors.Enable(services);
            ConfigContainerCore.Config(services);

            services.AddMvc().AddJsonOptions(options =>
            {
                options.SerializerSettings.Converters.Add(new Common.API.Converters.DateTimePtBrConverter());
            });
        }
Exemple #8
0
        public void ConfigureServices(IServiceCollection services)
        {
            var cnsCalemas = Configuration.GetSection("EFCoreConnStrings:Calemas").Value;

            services.AddDbContext <DbContextCore>(options => options.UseSqlServer(cnsCalemas));

            services.AddIdentityServer()
            .AddInMemoryIdentityResources(Config.GetIdentityResources())
            .AddInMemoryApiResources(Config.GetApiResources())
            .AddInMemoryClients(Config.GetClients())
            .AddSigningCredential(GetRSAParameters());

            services.AddScoped <CurrentUser>();
            services.AddTransient <IColaboradorRepository, ColaboradorRepository>();
            services.AddTransient <IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);

            Cors.Enable(services);

            services.AddMvc();
        }
        // 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 <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.Configure <ConfigConnectionStringBase>(Configuration.GetSection("ConfigConnectionString"));
            services.AddSingleton <IConfiguration>(Configuration);

            var authorityEndPoint = Configuration.GetSection("ConfigSettings:AuthorityEndPoint").Value;

            services.AddAuthentication(options =>
            {
                options.DefaultScheme          = "Cookies";
                options.DefaultChallengeScheme = "oidc";
            })
            .AddCookie("Cookies")
            .AddOpenIdConnect("oidc", options =>
            {
                options.SignInScheme = "Cookies";

                options.Authority            = authorityEndPoint;
                options.RequireHttpsMetadata = false;

                options.ClientId   = "hangfire-dash";
                options.SaveTokens = true;
            });

            // Add cross-origin resource sharing services Configurations
            Cors.Enable(services);

            var connectionString = Configuration.GetSection("ConfigConnectionString:Default").Value;

            //services.AddHangfire(x => x.UseSqlServerStorage(connectionString));
            services.AddHangfire(x => x.UseMemoryStorage());

            // Add application services.
            ConfigContainer.Config(services);

            services.AddMvc();
        }
Exemple #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Camelcase para json
            services.AddMvc()
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
            });

            services.AddDbContext <DbContextSeed>(
                options => options.UseSqlServer(
                    Configuration
                    .GetSection("ConfigConnectionString:Default").Value));

            services.AddDistributedRedisCache(options =>
            {
                options.Configuration = Configuration.GetSection("RedisConnStrings:Seed").Value;
                options.InstanceName  = "Seed";
            });

            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);

            // Add cross-origin resource sharing services Configurations
            Cors.Enable(services);

            // Add application services.
            ConfigContainerSeed.Config(services);

            // Add framework services.
            services.AddMvc(options => { options.ModelBinderProviders.Insert(0, new DateTimePtBrModelBinderProvider()); })
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.Converters.Add(new DateTimePtBrConverter());
            });
        }
        public void ConfigureServices(IServiceCollection services)
        {
            var cns =
                Configuration
                .GetSection("ConfigConnectionString:Default").Value;


            services.AddIdentityServer()
            //.AddSigningCredential(GetRSAParameters())
            .AddTemporarySigningCredential()
            .AddInMemoryApiResources(Config.GetApiResources())
            .AddInMemoryIdentityResources(Config.GetIdentityResources())
            .AddInMemoryClients(Config.GetClients(Configuration.GetSection("ConfigSettings").Get <ConfigSettingsBase>()));

            //for clarity of the next piece of code
            services.AddScoped <CurrentUser>();
            services.AddTransient <IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);

            // Add cross-origin resource sharing services Configurations
            Cors.Enable(services);
            services.AddMvc();
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Camelcase para json
            services.AddMvc()
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver();
            });

            services.AddDbContext <DbContextSeed>(
                options => options.UseSqlServer(
                    Configuration
                    .GetSection("ConfigConnectionString:Default").Value));

            services.AddDistributedRedisCache(options =>
            {
                options.Configuration = Configuration.GetSection("RedisConnStrings:Seed").Value;
                options.InstanceName  = "Seed";
            });

            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddSingleton(new EnviromentInfo
            {
                RootPath = this._env.ContentRootPath
            });

            // Config AuthorityEndPoint SSO
            services.AddAuthentication("Bearer")
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority            = Configuration.GetSection("ConfigSettings:AuthorityEndPoint").Value;
                options.RequireHttpsMetadata = false;
                options.ApiName = "ssosa";
            });


            // Add cross-origin resource sharing services Configurations
            var sp            = services.BuildServiceProvider();
            var configuration = sp.GetService <IOptions <ConfigSettingsBase> >();

            Cors.Enable(services, configuration.Value.ClientAuthorityEndPoint.ToArray());

            // Add application services.
            ConfigContainerSeed.Config(services);

            // Add framework services.
            services.AddMvc(options => { options.ModelBinderProviders.Insert(0, new DateTimePtBrModelBinderProvider()); })
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.Converters.Add(new DateTimePtBrConverter());
            });

            //Policys
            services.AddAuthorizationPolicy(ProfileCustom.Define);
            // Configurando o serviço do Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new Info
                {
                    Title       = "Seed",
                    Version     = "v1",
                    Description = "Seed",
                });

                var caminhoAplicacao = PlatformServices.Default.Application.ApplicationBasePath;
                var nomeAplicacao    = PlatformServices.Default.Application.ApplicationName;
                var caminhoXmlDoc    = Path.Combine(caminhoAplicacao, $"{nomeAplicacao}.xml");
                c.IncludeXmlComments(caminhoXmlDoc);

                c.AddSecurityDefinition("oauth2", new OAuth2Scheme
                {
                    Type             = "oauth2",
                    Flow             = "implicit",
                    AuthorizationUrl = "http://localhost:4000/connect/authorize",
                    Scopes           = new Dictionary <string, string>
                    {
                        { "ssosa", "ssosa" },
                    }
                });
                c.OperationFilter <AuthorizeCheckOperationFilter>();
            });
        }
Exemple #13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers().AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
                options.JsonSerializerOptions.IgnoreNullValues     = true;
                options.JsonSerializerOptions.WriteIndented        = false;
                options.JsonSerializerOptions.AllowTrailingCommas  = true;
                options.JsonSerializerOptions.Converters.Add(new StringJsonConverter());
            });


            services.AddDbContext <DbContextSeed>(
                options => options.UseSqlServer(
                    Configuration
                    .GetSection("ConfigConnectionString:Default").Value));

            services.AddDistributedRedisCache(options =>
            {
                options.Configuration = Configuration.GetSection("ConfigCache:Default").Value;
                options.InstanceName  = "Seed";
            });

            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.Configure <ConfigStorageConnectionStringBase>(Configuration.GetSection("ConfigStorage"));
            services.AddSingleton <IConfiguration>(Configuration);
            services.AddSingleton(new EnviromentInfo
            {
                RootPath = this._env.ContentRootPath
            });
            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.AddConfiguration(Configuration.GetSection("Logging"));
                loggingBuilder.AddConsole();
                loggingBuilder.AddDebug();
            });

            // Config AuthorityEndPoint SSO
            services.AddAuthentication("Bearer")
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority            = Configuration.GetSection("ConfigSettings:AuthorityEndPoint").Value;
                options.RequireHttpsMetadata = false;
                options.ApiName = "ssosa";
            });


            // Add cross-origin resource sharing services Configurations
            var sp            = services.BuildServiceProvider();
            var configuration = sp.GetService <IOptions <ConfigSettingsBase> >();

            Cors.Enable(services, configuration.Value.ClientAuthorityEndPoint.ToArray());


            services.AddAutoMapper(AutoMapperConfigSeed.RegisterMappings());

            // Add application services.
            ConfigContainerSeed.Config(services);

            // Add framework services.
            //services.AddMvc(options =>
            //{
            //    options.ModelBinderProviders.Insert(0, new DateTimePtBrModelBinderProvider());
            //    options.ModelBinderProviders.Insert(1, new NumberModelBinderProvider());
            //});
            //.AddNewtonsoftJson();

            // TODO : MIGRAÇÃO PROBLEMA 02
            //.AddJsonOptions(options =>
            //{
            //    options.SerializerSettings.Converters.Add(new DateTimePtBrConverter());
            //    options.SerializerSettings.Converters.Add(new DecimalPtBrConverter());
            //});

            //Policys
            services.AddAuthorizationPolicy(ProfileCustom.Define);
            // Configurando o serviço do Swagger
            //services.AddSwaggerGen(c =>
            //{
            //    c.SwaggerDoc("v1",
            //        new Info
            //        {
            //            Title = "Target.Intranet",
            //            Version = "v1",
            //            Description = "Target.Intranet",

            //        });

            //    var caminhoAplicacao = PlatformServices.Default.Application.ApplicationBasePath;
            //    var nomeAplicacao = PlatformServices.Default.Application.ApplicationName;
            //    var caminhoXmlDoc = Path.Combine(caminhoAplicacao, $"{nomeAplicacao}.xml");
            //    c.IncludeXmlComments(caminhoXmlDoc);

            //    c.AddSecurityDefinition("oauth2", new OAuth2Scheme
            //    {
            //        Type = "oauth2",
            //        Flow = "implicit",
            //        AuthorizationUrl = "http://localhost:4000/connect/authorize",
            //        Scopes = new Dictionary<string, string>
            //        {
            //            { "ssosa", "ssosa" },
            //        }
            //    });
            //    c.OperationFilter<AuthorizeCheckOperationFilter>();
            //});
        }
Exemple #14
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <DbContextTarget>(
                options => options.UseSqlServer(
                    Configuration
                    .GetSection("EFCoreConnStrings:Target").Value));

            services.AddDistributedRedisCache(options =>
            {
                options.Configuration = Configuration.GetSection("RedisConnStrings:Target").Value;
                options.InstanceName  = "Target";
            });

            services.Configure <ConfigSettingsBase>(Configuration.GetSection("ConfigSettings"));
            services.AddSingleton <IConfiguration>(Configuration);

            // Add cross-origin resource sharing services Configurations
            Cors.Enable(services);

            // Add application services.
            ConfigContainerTarget.Config(services);

            // Add framework services.
            services.AddMvc(options => { options.ModelBinderProviders.Insert(0, new DateTimePtBrModelBinderProvider()); });
            services.AddMvc().AddJsonOptions(options =>
            {
                options.SerializerSettings.Converters.Add(new DateTimePtBrConverter());
            });

            // Configurando o serviço de documentação do Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new Info
                {
                    Title       = "Target Pendencias",
                    Version     = "v1",
                    Description = "API Target Pendencias",
                    Contact     = new Contact
                    {
                        Name = "Wilson Santos",
                        Url  = "http://targetsoftware.com.br"
                    },
                });

                var caminhoAplicacao = PlatformServices.Default.Application.ApplicationBasePath;
                var nomeAplicacao    = PlatformServices.Default.Application.ApplicationName;
                var caminhoXmlDoc    = Path.Combine(caminhoAplicacao, $"{nomeAplicacao}.xml");

                c.IncludeXmlComments(caminhoXmlDoc);


                //c.AddSecurityDefinition("oauth2", new OAuth2Scheme
                //{
                //    Type = "oauth2",
                //    Flow = "implicit",
                //    AuthorizationUrl = "http://localhost:4000/connect/authorize",
                //    Scopes = new Dictionary<string, string>
                //    {
                //        { "ssosa", "ssosa" },
                //    }
                //});
                //c.OperationFilter<SecurityRequirementsOperationFilter>();


                c.AddSecurityDefinition("Bearer", new ApiKeyScheme()
                {
                    Description = "JWT Authorization header using the Bearer scheme. Example: \"Bearer {token}\"",
                    Name        = "Authorization",
                    In          = "header",
                    Type        = "apiKey"
                });
            });
        }