gpt4 book ai didi

sustainsys-saml2 - 如何在现有的网络核心应用程序中使用 Sustainsys.Saml2.AspNetCore2?

转载 作者:行者123 更新时间:2023-12-04 13:42:54 24 4
gpt4 key购买 nike

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

在引用示例应用程序之后,我到目前为止所做的事情:
1. 通过 nuget 引用最新的 Sustainsys.Saml2.AspNetCore2 和 Sustainsys.Saml2
2.修改Startup.cs添加新选项
3. 使用 ACS 端点创建 MVC Controller

我试图理解的事情:
1. 我是否需要启动 Saml2Handler 以便我可以点击库的 HandleRequestAsync() 端点。
2. 如何检索本金/ claim
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 并将其注入(inject) SSo Controller ?我在此 ASPNETSAMPLE 中找不到确切的终点saml2/ACS 项目?

我错过了什么?

最佳答案

Acs 端点内置于处理程序中。删除您的 SsoController。

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

关于sustainsys-saml2 - 如何在现有的网络核心应用程序中使用 Sustainsys.Saml2.AspNetCore2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54225655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com