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();
}
}
@saltanaa
Copy link

saltanaa commented Jun 25, 2020

Hi, i want to use saml code for asp.net core. i need post user to login url, then comeback user to me. Also i have certifacate. I want just one class. Other examples are very complex. too many folders, too many codes. I dont need them. Can you help me pls

@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