Skip to content

Instantly share code, notes, and snippets.

@CarlosLanderas
Last active November 15, 2020 20:43
Show Gist options
  • Save CarlosLanderas/d636fa39fa07498c402af70ccdb7fba6 to your computer and use it in GitHub Desktop.
Save CarlosLanderas/d636fa39fa07498c402af70ccdb7fba6 to your computer and use it in GitHub Desktop.
Single Sign Asp.Net Core Server
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();
}
}
@zeinabkamel
Copy link

if you found solution please share with me i face what you faced @saltanaa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment