Created
February 27, 2018 16:52
-
-
Save mshindal/02e4bde492b3f14996a801220214b249 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.SpaServices.Webpack; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using Newtonsoft.Json.Serialization; | |
using System.Net; | |
using Owin; | |
using Microsoft.AspNetCore.Authentication.Cookies; | |
using Microsoft.AspNetCore.Authentication.WsFederation; | |
namespace Foo.Bar | |
{ | |
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
// This method gets called by the runtime. Use this method to add services to the container. | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc().AddJsonOptions(o => o.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver()); | |
services.AddAuthentication(options => | |
{ | |
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; | |
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; | |
options.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme; | |
}) | |
.AddWsFederation(options => | |
{ | |
options.Wtrealm = "https://localhost:44363/foobar"; | |
options.MetadataAddress = "https://win-9j9dv1tr92n/security/FederationMetadata/2007-06/FederationMetadata.ashx"; | |
options.Wreply = "https://localhost:44363/foobar"; | |
}) | |
.AddCookie(); | |
} | |
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
app.UseExceptionMiddleware(); | |
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions | |
{ | |
HotModuleReplacement = true, | |
ReactHotModuleReplacement = true | |
}); | |
/* This will cause all HTTPS certificates to be validated, regardless of if they're trusted or not. | |
* It should NOT be used in production. */ | |
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; | |
} | |
else | |
{ | |
app.UseExceptionMiddleware(); | |
app.UseExceptionHandler(); | |
} | |
app.UseAuthentication(); | |
app.UseStaticFiles(); | |
app.UseMvc(routes => | |
{ | |
routes.MapRoute( | |
name: "areaRoute", | |
template: "{area:exists}/{controller}/{action}"); | |
/*routes.MapSpaFallbackRoute( | |
name: "spa-fallback", | |
defaults: new { controller = "Home", action = "Index" }); */ | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment