Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var MYPS = $"User ID=hgtadmin;Password={Environment.GetEnvironmentVariable("CPASS")};Host=hgtinstance.csftqsjshidx.ap-south-1.rds.amazonaws.com;Port=5432;Database=hgtDB;Pooling=true;";

            services.AddDbContext <HGTDbContext>(options =>
                                                 options.UseSqlServer(Configuration.GetConnectionString("HGTDB")));
            // options.UseNpgsql(MYPS));

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = Configuration["ValidIssuer"],
                    ValidAudience    = Configuration["ValidAudience"],
                    IssuerSigningKey = new SymmetricSecurityKey(
                        Encoding.UTF8.GetBytes(Configuration["SecurityKey"]))
                };
            });

            services.AddTransient <IEmailSender, AuthMessageSender>();
            services.AddCors();
            services.AddMvc();

            services.AddScoped <ILogger, Logger>();
            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });

            services.AddDefaultAWSOptions(ConfigurationRoot.GetAWSOptions());
            //AWSOptions awsOption = new AWSOptions();
            //awsOption.Region = RegionEndpoint.APSoutheast1;
            //awsOption.Credentials = new AWSCredentials();
            services.AddAWSService <IAmazonS3>();
            services.Configure <FormOptions>(options =>
            {
                options.MultipartBodyLengthLimit = 52428800;
            });
        }