Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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
使用Thinktecture';s Owin方法:使用Saml2BearAuthentication_Authentication_Asp.net Web Api_Owin_Ws Federation_Thinktecture Ident Model - Fatal编程技术网

使用Thinktecture';s Owin方法:使用Saml2BearAuthentication

使用Thinktecture';s Owin方法:使用Saml2BearAuthentication,authentication,asp.net-web-api,owin,ws-federation,thinktecture-ident-model,Authentication,Asp.net Web Api,Owin,Ws Federation,Thinktecture Ident Model,我正在为我的公司做一个WSPOC。该解决方案还应与MVC应用程序和webapi服务配合使用。 我想出了如何让它在MVC应用程序上工作,使用新的OWIN认证中间件。 在这一点上,我得到了SAML2代币 现在,我想通过ajax调用从webapi控制器调用一个方法,在授权头中传递SAML令牌,如javascript中所示: var token = '@ViewBag.Token'; var request = { url: 'https://localhost

我正在为我的公司做一个WSPOC。该解决方案还应与MVC应用程序和webapi服务配合使用。 我想出了如何让它在MVC应用程序上工作,使用新的OWIN认证中间件。 在这一点上,我得到了SAML2代币

现在,我想通过ajax调用从webapi控制器调用一个方法,在授权头中传递SAML令牌,如javascript中所示:

var token = '@ViewBag.Token';

        var request = {
            url: 'https://localhost:44305/api/test/GetStrings',
            cache: false,
            beforeSend: function (xhr) {
                xhr.setRequestHeader('Authorization', 'bearer ' + token);
            },
            type: 'GET',
            crossDomain: true,
            success: function () {
                alert('ok');
            },
            error: function () {
                alert('ko');
            }
        };

        $.ajax(request);
在Firebug(或同等版本)中,我可以看到头部使用令牌填充得很好

在服务器端,我尝试使用Thinktecture的Owin扩展方法来检索和检查令牌:

 app.UseSaml2BearerAuthentication(
            new Uri("urn:relyingparty2"),
            "3AA702552....643E27150591A9",
            "http://localSTS")
            ;
正如我在这里读到的:

但似乎什么也没发生

我希望避免添加消息处理程序,因为这个方法看起来应该完成我所寻找的任务


有什么想法吗

您如何在服务器上生成令牌?Thinktecture是WIF和Owin处理程序之间的桥梁,因此您需要在webconfig中设置所有WIF内容,并在配置中正确安装和引用您的证书;所以我可能误解了Thinktecture。我假设这会使配置变得不必要。令牌由Identity server(v2)生成,目前。。。那么,对于我想要实现的目标,什么样的模式才是最好的呢?