itfoxtec-identity-saml2 - ITfoxtec SAML 2.0 和 ASP.NET Web 表单 (ASPX) HttpRequest

标签 itfoxtec-identity-saml2

我正在尝试在 ASP.NET Web Forms (ASPX) 应用程序中实现 ITfoxtec SAML 2.0。

通常的 ASP.NET MVC 实现使用以下语句:

binding.ReadSamlResponse(Request.ToGenericHttpRequest(), saml2AuthnResponse);

但 MVC Request 在 Web 表单中不可用。

在 VB 中我尝试过如下代码

Dim request As New ITfoxtec.Identity.Saml2.Http.HttpRequest
request.Method = "GET"
request.Query = HttpContext.Current.Request.Form

binding.ReadSamlResponse(request, saml2AuthnResponse)

但这引发了异常:

Found invalid data while decoding.
at System.IO.Compression.InflaterZlib.Inflate(FlushCode flushCode)
at System.IO.Compression.InflaterZlib.ReadInflateOutput(Byte[] outputBuffer, Int32 offset, Int32 length, FlushCode flushCode, Int32& bytesRead)
at System.IO.Compression.InflaterZlib.Inflate(Byte[] bytes, Int32 offset, Int32 length)
at System.IO.Compression.DeflateStream.Read(Byte[] array, Int32 offset, Int32 count)
at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize)
at System.IO.Stream.CopyTo(Stream destination)
at ITfoxtec.Identity.Saml2.Saml2RedirectBinding.DecompressResponse(String value)
at ITfoxtec.Identity.Saml2.Saml2RedirectBinding.Read(HttpRequest request, Saml2Request saml2RequestResponse, String messageName, Boolean validateXmlSignature, Boolean detectReplayedTokens)
at ITfoxtec.Identity.Saml2.Saml2Binding`1.ReadSamlResponse(HttpRequest request, Saml2Response saml2Response)
at [my code]

如何将 HttpContext.Current.Request 转换为 ITfoxtec.Identity.Saml2.Http.HttpRequest

希望得到帮助,

大卫。

最佳答案

谢谢安德斯。

我之所以出现这个问题,是因为我无意中将 binding 声明为 Saml2RedirectBinding 而不是 Saml2PostBinding。更正此问题后,ASP.NET MVC C# 语句:

binding.ReadSamlResponse(Request.ToGenericHttpRequest(), saml2AuthnResponse);

对于 VB 中的 ASP.NET Web 窗体,需要如下所示:

Dim request As New ITfoxtec.Identity.Saml2.Http.HttpRequest With
{
 .Method = HttpContext.Current.Request.HttpMethod,
 .Form = HttpContext.Current.Request.Form,
 .Query = New NameValueCollection,
 .QueryString = ""
}
binding.ReadSamlResponse(request, saml2AuthnResponse)

以防其他人需要此解决方案。

大卫。

关于itfoxtec-identity-saml2 - ITfoxtec SAML 2.0 和 ASP.NET Web 表单 (ASPX) HttpRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70735069/

相关文章:

itfoxtec-identity-saml2 - 在 NemLog-in 中为一家私营公司创建 IT 系统

c# - SAML 与 ASP.NET Core Identity 的集成

azure - Azure 上的 SAML 绑定(bind) : Error getting X509Certificate2. 私钥

encryption - ITfoxtec SAML 2.0 加密断言

asp.net-core - 我可以发送没有主题属性的 Saml2AuthnRequest 吗? Azure AD 不支持 'Subject'

ssl - ITfoxtec - ADFS SAML2 根据验证程序,远程证书无效

asp.net-core - .net 核心和 SAML 2.0

saml-2.0 - IDP 与 ITfoxtec 启动了 SAML 流程