I am using a great SAML 2.0 library called ITFoxTec in my .Net Core 2.1 Web Application.
I have everything setup based on the multiple examples and tutorials available on the web.
I have a Login landing page where the user can either press a Local Login button or a SAML Login button.
One of the pieces of code needed is this line in the Startup.cs class in the ConfigureServices
section:
// ** ITFoxTec SAML(services.AddSaml2())
services.AddSaml2();
services.AddMvc();
var builder = CompositionRoot.MakeContainerBuilder(RunConfig);
builder.Populate(services);
ApplicationContainer = builder.Build();
And then in my Configure
section, I have this:
app.UseMvc(routes => {
routes.MapRoute(
"spa-fallback",
"{*clientRoute}",
new { controller = "Home", action = "Index" },
new { clientRoute = new SpaRouteConstraint("clientRoute") },
null
);
});
// ** ITFoxTec SAML (app.UseSaml2())
app.UseSaml2();
However, when I put that in(services.AddSaml2()) and run the web app, it is directing me to the IdP immediately…bypassing my Login page.
If I leave it out, the app works fine and goes to my Login page.
However, with it out, and I click the SAML Login Button, the IdP returns an error that just says Bad Request 400.
So is there a way to add services.AddSaml2();
dynamically when I click the “SAML Login” button?