如何解决如何在.NET Core 3.1中将Azure AD Saml2身份验证用于SSO
我正在使用Sustainsys.Saml2进行.NET Core 3.1中的Azure AD Saml2身份验证。我可以进行身份验证,但是将登录页面重定向到此地址后https:// localhost:44378 / Saml2 / Acs.system添加“ / Saml2 / Acs”。我找不到使用此软件的正确教程。我需要正确使用回复网址。成功通过身份验证后,我需要调用特定的控制器。
// 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));
});
错误消息是
找不到该本地主机页面未找到以下网址的网址:https:// localhost:44378 / Saml2 / Acs HTTP错误404
解决方法
您需要添加 app.UseAuthentication();在 Startup 类中的 Configure 方法下。
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseAuthentication();
}
}
这将在您的应用程序中启用 SAML2 中间件。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。