I am using Sustainsys.Saml2 for Azure AD Saml2 authentication in .NET Core 3.1.I can able to authenticate, but after the login page is redirected to this address https://localhost:44378/Saml2/Acs.system automatically adding "/Saml2/Acs".I could not find the correct tutorial for using this. I need to use the reply URL properly. once successfully authenticated I need to call a particular controller.
// Startup.cs class
services.AddAuthentication(sharedOptions =>
{
sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
sharedOptions.DefaultChallengeScheme = "Saml2";
})
.AddSaml2(options =>
{
options.SPOptions.EntityId = new EntityId("https://localhost:44378/Saml2");
options.IdentityProviders.Add(
new IdentityProvider(
new EntityId("https://sts.windows.net/9e5692e4-bd0a-414d-8b61-98f59dab156e/"), options.SPOptions)
{
MetadataLocation = "https://login.microsoftonline.com/7e5692e4-bgf0a-4148-8b61-98f59dab156e/federationmetadata/2007-06/federationmetadata.xml?appid=1729db2f-0156-41cb-b4e3-d54bed555b85"
});
})
.AddCookie();
services.AddMvc(options =>
{
var policy = new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
options.Filters.Add(new AuthorizeFilter(policy));
});
error msg is
This localhost page can't be found No webpage was found for the web address: https://localhost:44378/Saml2/Acs HTTP ERROR 404
You need to add app.UseAuthentication(); under your Configure method in the Startup class.
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseAuthentication();
}
}
This will enable the SAML2 middleware in your application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.