Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WIF无法在联合身份验证后重定向到包含哈希的URL_Wif_Single Page Application_Federated Identity_Thinktecture Ident Server_Thinktecture Ident Model - Fatal编程技术网

WIF无法在联合身份验证后重定向到包含哈希的URL

WIF无法在联合身份验证后重定向到包含哈希的URL,wif,single-page-application,federated-identity,thinktecture-ident-server,thinktecture-ident-model,Wif,Single Page Application,Federated Identity,Thinktecture Ident Server,Thinktecture Ident Model,我正在使用WIF和使用ThinktectureSTS的联邦安全模型 当我尝试请求url:时,WIF在身份验证后没有重定向到正确的页面 wctx中的ru参数不包含/#path的正确路径。相反,它会忽略散列及其后的所有内容,因此ru参数只是/。没有散列的普通url可以正常工作 是否有解决方案,或者我的url格式是否错误?有什么建议吗?看起来是浏览器没有将url的哈希部分发送回服务器。我相信这是一个HTTP标准,因为散列部分最初只用于客户端锚标记 使用ajax/javascript有一些变通方法,但由

我正在使用WIF和使用ThinktectureSTS的联邦安全模型

当我尝试请求url:时,WIF在身份验证后没有重定向到正确的页面

wctx中的ru参数不包含/#path的正确路径。相反,它会忽略散列及其后的所有内容,因此ru参数只是/。没有散列的普通url可以正常工作


是否有解决方案,或者我的url格式是否错误?
有什么建议吗?

看起来是浏览器没有将url的哈希部分发送回服务器。我相信这是一个HTTP标准,因为散列部分最初只用于客户端锚标记

使用ajax/javascript有一些变通方法,但由于我使用的是一个简单的GET请求,这似乎是不可能的

看看这些类似的问题,它们解释了问题


看起来是浏览器没有将url的哈希部分发送回服务器。我相信这是一个HTTP标准,因为散列部分最初只用于客户端锚标记

使用ajax/javascript有一些变通方法,但由于我使用的是一个简单的GET请求,这似乎是不可能的

看看这些类似的问题,它们解释了问题


这就是散列片段的全部要点-它们不会在服务器上结束。

这就是散列片段的全部要点-它们不会在服务器上结束。

您可以通过发出JavaScript来执行重定向,而不是立即重定向来保留散列部分。JavaScript代码可以通过window.location.hash访问散列部分,并使用它来构建ru

您需要将页面配置为允许未经身份验证的用户(以便WIF被动身份验证不会生效)。然后,您可以在页面代码中处理未经验证的用户

您可以在应用程序启动代码(例如Web表单中的Global.asax.cs)中挂接FederatedAuthentication.WSFederationAuthenticationModule.RedirectingToIdentityProvider事件

例如(网络表单):

公共类全局:HttpApplication
{
受保护的无效应用程序\u启动(对象发送方,事件参数e)
{
FederatedAuthentication.WSFederationAuthenticationModule.RedirectingToIdentityProvider
+=this.RedirectToIdentityProviderViaJavaScript;
}
常量字符串重定向HTML=
@"
函数身份验证(url、utcTimeString){{
var ru=window.location.pathname+(window.location.hash | |“”);
var wctx='rm=0&id=passive&ru='+encodeURIComponent(ru)+'&wtc='+encodeURIComponent(utcTimeString);
url+='&wctx='+encodeURIComponent(wctx);
window.location=url;
}}
";
私有void RedirectToIdentityProviderViaJavaScript(对象发送方,RedirectingToIdentityProviderEventArgs e)
{
var fam=FederatedAuthentication.WSFederationAuthenticationModule;
var msg=newsignirequestmessage(新Uri(fam.Issuer)、fam.Realm);
var stsUrl=msg.WriteQueryString();
var utcTime=webageroutines.EncodeUtcTimeString(DateTime.Now);
var html=string.Format(重定向html、WebPageRoutines.JavascriptEncode(stsUrl)、WebPageRoutines.JavascriptEncode(utcTime));
Response.ClearContent();
Response.Write(html);
响应。状态=“200正常”;
Response.End();
}
}
有人警告你不能混音吗?使用此方法,参数带有#个零件。ru在STS重定向(Thinktecture IdentityServer v2)中幸存下来,但WIF似乎在从STS发帖后的最终重定向中把它搞砸了。

它将放置?一部分接一部分。

变成:



您可以通过发出JavaScript来执行重定向来保留哈希部分,而不是立即重定向。JavaScript代码可以通过window.location.hash访问散列部分,并使用它来构建ru

您需要将页面配置为允许未经身份验证的用户(以便WIF被动身份验证不会生效)。然后,您可以在页面代码中处理未经验证的用户

您可以在应用程序启动代码(例如Web表单中的Global.asax.cs)中挂接FederatedAuthentication.WSFederationAuthenticationModule.RedirectingToIdentityProvider事件

例如(网络表单):

公共类全局:HttpApplication
{
受保护的无效应用程序\u启动(对象发送方,事件参数e)
{
FederatedAuthentication.WSFederationAuthenticationModule.RedirectingToIdentityProvider
+=this.RedirectToIdentityProviderViaJavaScript;
}
常量字符串重定向HTML=
@"
函数身份验证(url、utcTimeString){{
var ru=window.location.pathname+(window.location.hash | |“”);
var wctx='rm=0&id=passive&ru='+encodeURIComponent(ru)+'&wtc='+encodeURIComponent(utcTimeString);
url+='&wctx='+encodeURIComponent(wctx);
window.location=url;
}}
";
私有void RedirectToIdentityProviderViaJavaScript(对象发送方,RedirectingToIdentityProviderEventArgs e)
{
var fam=FederatedAuthentication.WSFederationAuthenticationModule;
var msg=newsignirequestmessage(新Uri(fam.Issuer)、fam.Realm);
var stsUrl=msg.WriteQueryString();
var utcTime=webageroutines.EncodeUtcTimeString(DateTime.Now);
var html=string.Format(重定向html、WebPageRoutines.JavascriptEncode(stsUrl)、WebPageRoutines.JavascriptEncode(utcTime));
Response.ClearContent();
public class Global : HttpApplication
{
    protected void Application_Start(object sender, EventArgs e)
    {
        FederatedAuthentication.WSFederationAuthenticationModule.RedirectingToIdentityProvider 
        += this.RedirectToIdentityProviderViaJavaScript;
    }

    const string RedirectHtml =
    @"<html>
        <head>
            <script type='text/javascript'>
                function authenticate(url, utcTimeString) {{
                    var ru = window.location.pathname + (window.location.hash || '');
                    var wctx = 'rm=0&id=passive&ru=' + encodeURIComponent(ru) + '&wtc=' + encodeURIComponent(utcTimeString);
                    url += '&wctx=' + encodeURIComponent(wctx);
                    window.location = url;
                }}
            </script>
        </head>
        <body onload=""authenticate('{0}', '{1}');"">
        </body>
    </html>";

    private void RedirectToIdentityProviderViaJavaScript(object sender, RedirectingToIdentityProviderEventArgs e)
    {
        var fam = FederatedAuthentication.WSFederationAuthenticationModule;
        var msg = new SignInRequestMessage(new Uri(fam.Issuer), fam.Realm);
        var stsUrl = msg.WriteQueryString();
        var utcTime = WebPageRoutines.EncodeUtcTimeString(DateTime.Now);
        var html = string.Format(RedirectHtml, WebPageRoutines.JavascriptEncode(stsUrl), WebPageRoutines.JavascriptEncode(utcTime));
        Response.ClearContent();
        Response.Write(html);
        Response.Status = "200 OK";
        Response.End();
    }
}
        const string redirectHtml =
            @"<!DOCTYPE html>
              <html>
                <head>
                    <meta charset='utf-8'>
                    <script type='text/javascript'>
                        function authenticate(url) {{
                            var ru = window.location.pathname + (window.location.hash || '');
                            window.location = url.replace('REPLACEWITHURL', encodeURIComponent(ru));
                        }}
                    </script>
                </head>
                <body onload=""authenticate('{0}');"">
                </body>
            </html>";

        var authenticationModule = FederatedAuthentication.WSFederationAuthenticationModule;
        var message = authenticationModule.CreateSignInRequest("passive", "REPLACEWITHURL", false);
        var stsUrl = message.WriteQueryString();
        var html = string.Format(redirectHtml, HttpUtility.JavaScriptStringEncode(stsUrl));
        filterContext.Result = new ContentResult { Content = html };