// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var key = AuthOptions.GenerateKey(); //services.AddCors(options => //{ // options.AddDefaultPolicy(builder => builder // .WithOrigins("http://localhost:8080") // .WithMethods("GET", "POST")); //}); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = Configuration.GetValue <string>($"Auth:{nameof(AuthOptions.Issuer)}"), ValidateAudience = true, ValidAudience = Configuration.GetValue <string>($"Auth:{nameof(AuthOptions.Audience)}"), ValidateLifetime = true, IssuerSigningKey = AuthOptions.GetSymmetricSecurityKey( Configuration.GetValue <string>($"Auth:{nameof(AuthOptions.SecurityKeyBase64)}")), ValidateIssuerSigningKey = true, }; }); services.AddControllersWithViews(); services.AddSignalR(); services.AddSwaggerGen(options => { options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "Cards.Front.xml")); }); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); services.AddDbContext <AppDbContext>(options => options.UseSqlite("Data Source=cards.db")); services.AddHttpClient("google") .ConfigureHttpClient((sp, client) => client.Timeout = TimeSpan.FromSeconds(10)); services.Configure <AuthOptions>(Configuration.GetSection("Auth")); services.AddAutoMapper(typeof(MappingProfile)); }