Last active
November 15, 2020 20:43
-
-
Save CarlosLanderas/d636fa39fa07498c402af70ccdb7fba6 to your computer and use it in GitHub Desktop.
Single Sign Asp.Net Core Server
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; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Identity; | |
using Microsoft.AspNetCore.Server.HttpSys; | |
namespace Api | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
new WebHostBuilder() | |
.UseUrls("http://localhost:56000") | |
.Configure(app => | |
{ | |
app.Run(async (context) => | |
{ | |
//Encrypt NTLM identity and redirect the application | |
context.Response.Redirect($"http://localhost:55960/#identity={context.User.Identity.Name}"); | |
}); | |
}) | |
.UseHttpSys(options => | |
{ | |
options.Authentication.Schemes = | |
AuthenticationSchemes.NTLM | AuthenticationSchemes.Negotiate; | |
options.Authentication.AllowAnonymous = false; | |
}) | |
.Build().StartAsync(); | |
BuildWebHost(args) | |
.MigrateDbContext<DbContext>(context => | |
{ | |
context.ApplySeed(); | |
}).ProvisionApplication() | |
.Run(); | |
} | |
public static IWebHost BuildWebHost(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.UseStartup<Startup>() | |
.Build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you found solution please share with me i face what you faced @saltanaa