首页 > 解决方案 > 我如何在 ASP.NetCore 2.1 mvc 应用程序中包含 System.Identity Model 4.0

问题描述

在 ASP.NetCore2.1 MVC 应用程序中实现 saml2.0 的最佳方法是什么?

我正在使用 Sustainsys.AspNetCore2.1Saml2 nuget,下面是代码。但其中的 EntityId 需要 System.IdentityModel.dll 4.0 听起来我无法运行它在错误下方显示的应用程序。

代码

 services.AddAuthentication()
           .AddSaml2(options =>
           {
               options.SPOptions.EntityId = new EntityId("https://localhost:44349/Saml2");
               options.IdentityProviders.Add(
                   new IdentityProvider(
                       new EntityId("http://localhost:59410//Metadata"), options.SPOptions)
                   {
                       LoadMetadata = true
                   });

               options.SPOptions.ServiceCertificates.Add(new X509Certificate2("Sustainsys.Saml2.Tests.pfx"));
           });

我得到以下错误

在此处输入图像描述

标签: saml-2.0asp.net-core-2.1sustainsys-saml2itfoxtec-identity-saml2

解决方案


您可以使用 ITfoxtec Identity Saml2 在 ASP.NET Core 2.1 中支持 SAML 2.0。NuGet 包:https ://www.nuget.org/packages/ITfoxtec.Identity.Saml2.MvcCore/

项目https://itfoxtec.com/IdentitySaml2和代码示例https://github.com/ITfoxtec/ITfoxtec.Identity.Saml2/tree/master/test


推荐阅读