如何使用ITfoxtec Identity SAML 2.0库配置SingleLogoutService的Respons



使用ITfoxtec Identity SAML 2.0库在我的.NET MVC应用程序中实现单一注销。

为了测试,我做了以下操作:

在同一浏览器中,在不同的选项卡中打开我的和另一个网络应用程序:

第一个场景是从两者中注销,从我的应用程序中启动注销,效果非常好。

然而,第二种情况是从两者中注销,但从另一个应用程序启动注销,在这里我收到来自IdP的错误:"无法完成注销请求。(目标URL验证失败-0F0E112110A00BEA("。如果我刷新那个屏幕,我会看到我已经注销了那个应用程序,但不是我的。仔细查看后,我发现,尽管我正在加载我的IdP的元数据,但似乎没有办法配置SingleLogoutService的ResponseLocation,就好像它只获取Location一样。有没有办法进行配置?

我有好几个星期都在处理这个问题。如果你能帮助我实现这一配置,我将不胜感激。

我的应用程序的元数据:

<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://templatenetframeworkmvcsaml.azurewebsites.net/Auth/SingleLogout" ResponseLocation="https://templatenetframeworkmvcsaml.azurewebsites.net/Auth/LoggedOut"/>

IdP的元数据:

<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://amfsdevl.tec.mx/nidp/saml2/slo" ResponseLocation="https://amfsdevl.tec.mx/nidp/saml2/slo_return"/>

相反,问题是IdP也有2个端点,并且在读取元数据时,它似乎只获取IdP的位置,而不获取ResponseLocation。或者只需从web.config中读取该设置,我将其设置为:

<add key="Saml2:SingleLogoutDestination" value="https://amfsdevl.tec.mx/nidp/saml2/slo" />

我找不到如何配置IdP的ResponseLocation,而这正是我们所缺少的,以实现不同于我的应用程序关闭会话的场景。

我分享了在这两种情况下发生的事情的跟踪器:

场景1.我从应用程序注销。https://templatenetframeworkmvcsaml.azurewebsites.net.这个场景使它变得完美。

POST https://templatenetframeworkmvcsaml.azurewebsites.net/Auth/Logout HTTP/1.1
POST https://amfsdevl.tec.mx/nidp/saml2/slo HTTP/1.1
GET https://test-edutools.tec.mx/simplesaml/module.php/saml/sp/saml2-logout.php/tec-sp?SAMLRequest= HTTP/1.1
GET https://amfsdevl.tec.mx/nidp/saml2/slo_return?SAMLResponse= HTTP/1.1
POST https://templatenetframeworkmvcsaml.azurewebsites.net/Auth/LoggedOut HTTP/1.1
GET https://templatenetframeworkmvcsaml.azurewebsites.net/ HTTP/1.1
GET https://templatenetframeworkmvcsaml.azurewebsites.net/Auth/Login?ReturnUrl=%2f HTTP/1.1

在我的应用程序中:

它显示了我的登录页面。(已从我的应用程序中注销。(

在其他应用程序中:

保持屏幕原样,但如果我更改到任何菜单选项,我会看到会话已关闭。

场景2.我从另一个应用程序注销。https://test-edutools.tec.mx/saml_login.此方案正在失败

GET https://test-edutools.tec.mx/es/user/logout HTTP/1.1
GET https://amfsdevl.tec.mx/nidp/saml2/slo?SAMLRequest= HTTP/1.1
POST https://templatenetframeworkmvcsaml.azurewebsites.net/Auth/SingleLogout HTTP/1.1
POST https://amfsdevl.tec.mx/nidp/saml2/slo HTTP/1.1

在我的应用程序中:

什么也没发生。如果我再次放置URL,我会看到会话继续。

在其他应用程序中:

显示此消息:

无法完成注销请求。(目标URL验证失败-0F0E112110A00BEA(

如果我再次输入URL,我会看到该会话已关闭。

在第二个场景中,不是在这里提出请求:

POST https://amfsdevl.tec.mx/nidp/saml2/slo HTTP/1.1

我的申请应该在这里提出请求:

POST https://amfsdevl.tec.mx/nidp/saml2/slo_return HTTP/1.1

这是另一个应用程序在场景1中所做的,并且可以正常工作。

ASP.NET核心示例为单个注销公开了两个不同的端点(Location和ResponseLocation(。ResponseLocation用于外部启动的单次注销。

元数据:https://github.com/ITfoxtec/ITfoxtec.Identity.Saml2/blob/master/test/TestWebAppCore/Controllers/MetadataController.cs#L44

AuthController:https://github.com/ITfoxtec/ITfoxtec.Identity.Saml2/blob/master/test/TestWebAppCore/Controllers/AuthController.cs#L91

您的IdP需要同时配置Location和ResponseLocation端点来执行外部启动的单次注销。

替代解决方案

单个注销位置端点是默认的,也是必需的。如果IdP不支持两个单独的注销端点,您可以扩展Location端点来支持这两种情况,请参阅FoxID中的SAML 2.0实现。

var genericHttpRequest = Request.ToGenericHttpRequest();
if (new Saml2PostBinding().IsResponse(genericHttpRequest) || new Saml2RedirectBinding().IsResponse(genericHttpRequest))
{
return await LoggedOutInternal();
}
else
{
return await SingleLogoutInternal();
}

4月4日编辑

错误A request for log out could not be completed. (Destination URL validation failed-0F0E112110A00BEA)health-of表示配置为调用"其他应用程序"的URL或配置为回调"我的应用程序"的URL不正确。

最新更新