Created
July 21, 2016 02:40
-
-
Save nzpcmad/6b6e71e6e86aaaf029ef10e9bc4fcff5 to your computer and use it in GitHub Desktop.
.NET Core MVC application to ADFS on Windows Server 2016
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
{ | |
"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" | |
} | |
} | |
} |
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
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
http://nzpcmad.blogspot.co.nz/2016/07/adfs-authentication-with-net-core.html