Skip to content

Instantly share code, notes, and snippets.

@nzpcmad
Created July 21, 2016 02:40
Show Gist options
  • Save nzpcmad/6b6e71e6e86aaaf029ef10e9bc4fcff5 to your computer and use it in GitHub Desktop.
Save nzpcmad/6b6e71e6e86aaaf029ef10e9bc4fcff5 to your computer and use it in GitHub Desktop.
.NET Core MVC application to ADFS on Windows Server 2016
{
"Authentication": {
"ADFS": {
// ADFS
"ClientId": "2c...b7",
"ClientSecret": "I7...fW",
"MetadataAddress": "https://myadfs/adfs/.well-known/openid-configuration",
"PostLogoutRedirectUri": "https://localhost:44344/"
}
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseCookieAuthentication();
// ADFS
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
ClientId = Configuration["Authentication:ADFS:ClientId"],
ClientSecret = Configuration["Authentication:ADFS:ClientSecret"],
ResponseType = OpenIdConnectResponseType.CodeIdToken,
MetadataAddress = Configuration["Authentication:ADFS:MetadataAddress"],
PostLogoutRedirectUri = Configuration["Authentication:ADFS:PostLogoutRedirectUri"]
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment