【问题标题】:How to use Sustainsys.Saml2.AspNetCore2 in existing net core app?如何在现有的网络核心应用程序中使用 Sustainsys.Saml2.AspNetCore2?
【发布时间】:2019-01-16 21:27:19
【问题描述】:

我正在尝试使用this saml2 库提供的 Sustainsys.Saml2 和 Sustainsys.Saml2.AspNetCore2 库来实现 IDP 启动和 SP 启动的场景。

在参考了我到目前为止所做的示例应用程序之后:
1. 通过 nuget 参考最新的 Sustainsys.Saml2.AspNetCore2 和 Sustainsys.Saml2
2. 修改 Startup.cs 添加新选项
3. 创建带有 ACS 端点的 MVC 控制器

我想了解的事情:
1. 我是否需要启动 Saml2Handler 以便我可以点击库的 HandleRequestAsync() 端点。
2. 如何检索委托人/索赔
3. sp 发起的情况,当端点识别请求未通过身份验证时,如何将请求重定向到 IDP?
startup.cs 中的ConfigureServices 方法

        public void ConfigureServices(IServiceCollection services)
            {
                services.AddAuthentication()
                    .AddSaml2(options => 
                    {
                        options.SPOptions.EntityId = new EntityId("https://localhost:3131/Saml2");
                        options.IdentityProviders.Add(
                            new IdentityProvider(
                                new EntityId("http://localhost:52071/Metadata"), options.SPOptions)
                            {
                                LoadMetadata = true
                            });

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

    **SSO Controller** 


            [Authorize(AuthenticationSchemes = "Saml2")] 
            public class SsoController : Controller
            {
                public SingleSignOnController(ILogger logger)
                {
                }

                [Route("saml2/ACS")]
                [HttpPost]
                public ActionResult ACS()
                {
                    try
                    {   
                    // Is request authenticated here by library? 
                    // I tried hitting this end point from stud idp portal, but it is    
  throwing " MVC Exception Handler: The method or operation is not implemented.    at Sustainsys.Saml2.AspNetCore2.Saml2Handler.AuthenticateAsync()
       at Microsoft.AspNetCore.Authentication.AuthenticationService"         
                    }
                    catch (Exception e)
                    {

                    }
                }
            }

我是否需要创建/实现自定义 Saml2Handler 并将其注入 SSo 控制器?我在这个ASPNETSAMPLE 项目中找不到 saml2/ACS 的确切终点?

我错过了什么?

【问题讨论】:

    标签: sustainsys-saml2


    【解决方案1】:

    Acs 端点内置于处理程序中。移除你的 SsoController。

    查看 repo 中的 asp.net 核心示例应用程序以获取有关如何配置的示例。 AspNetCore2 包包含一个处理程序,其工作方式与 Asp.NET Core 的任何其他外部身份验证处理程序相同。您通过身份验证质询启动登录顺序。

    【讨论】:

      猜你喜欢
      • 2020-11-23
      • 1970-01-01
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-30
      相关资源
      最近更新 更多