.NET Core
Authentication and Authorization in ASP.NET Core 2
public void ConfigureServices(IServiceCollection services) { // ... services.AddCors(); services.AddSingleton<IWorkService, WorkService>(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(o => o.LoginPath = new Microsoft.AspNetCore.Http.PathString("/login")) .AddGoogle(googleOptions => { googleOptions.ClientId = Configuration["Authentication:Google:ClientId"]; googleOptions.ClientSecret = Configuration["Authentication:Google:ClientSecret"]; }); services.AddAuthorization(options => { options.AddPolicy("authenticated", policy => { policy.AuthenticationSchemes.Add(GoogleDefaults.AuthenticationScheme); policy.RequireAuthenticatedUser(); }); }); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILogger<Startup> logger, IConfiguration config) { // ... app.UseAuthentication(); } References Authorize with a specific scheme in ASP.NET Core. aspnet/Security on GitHub. Using OAuth2 Middleware with ASP.
CORS on .NET Core 2 with Web API
How to enable CORS in ASP.net Core WebAPI Install-Package Microsoft.AspNetCore.Cors public void ConfigureServices(IServiceCollection services) { services.AddCors(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IConfiguration config) { // ... app.UseCors(options => options.WithOrigins("http://example.com") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); ); app.UseCors(builder => { var allowedOrigins = config.GetSection("AllowedOrigins").GetChildren().ToArray().Select(c => c.Value).ToArray(); logger.LogInformation("Allowed Origins: {0}", string.Join(", ", allowedOrigins)); builder.WithOrigins(allowedOrigins).AllowAnyMethod(); }); // ... } References original MSDN instructions based on StackOverflow discussion obsolete link contains instructions for older version of Web API (Web API 1).
WebSockets in ASP.NET Core 2
References How to use WebSocket with ASP.NET Core. WebSockets support in ASP.NET Core (2.1).