asp.net-mvc - 使用用户身份从移动客户端访问 WCF 服务

标签 asp.net-mvc wcf authentication mobile architecture

我正在开发一个具有 Web (ASP.NET MVC)、WCF 服务和移动接口(interface) (Android/iPhone) 的 Web API,并且我对 API 进行了 token 身份验证。

MVC 和 API 有用户身份来验证用户,但 WCF 服务不会有这个用户身份。

在这里,我需要安全地从移动客户端访问 WCF 服务。

应用结构,

enter image description here

那么,如何通过 WCF 服务验证或共享用户身份呢?

我可以在 WCF 服务中使用相同的 OAuth token 来识别用户吗?或者还有其他标准方法吗?

最佳答案

我有一个类似的应用程序。我使用以下方法添加 token (之前在身份验证后收到):

使用 jQuery 的常见 ajax 调用:

$.ajax({
    beforeSend: function (request)
    {
        request.setRequestHeader("Authority", authorizationToken);
    },
    // Below you set type, url, data, ...
});

在这里,使用 Cordova + Ionic + Angularjs:
$http.defaults.headers.common.Authorization = authorizationToken;
if ($http.defaults.headers.common.Authorization.Parameter != undefined) {
    $http.defaults.headers.common.Authorization.Parameter = authorizationToken;
}

希望能帮助到你。

关于asp.net-mvc - 使用用户身份从移动客户端访问 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40402694/

相关文章:

c# - 使用 SSL 的 .net Web 服务。 wcf?

asp.net - WCF 与 WebAPI 和 native 移动设备

c# - 如何将新的 Guid 添加到字符串列表?

c# - 'System.Management.Automation.Runspaces.InitialSessionState' 的类型初始值设定项抛出异常

javascript - 为什么 JavaScript 会识别出我的控件现在持有一个数组?

c# - ASP.net 中报告应用程序的最佳架构(带有动态源)

python - 我如何将 JWT 与 grpc 一起使用?

c# - 自动 URL 参数编码失败

performance - 网站中 ASP.NET HttpHandler 和 WCF 客户端的 IIS 性能瓶颈

authentication - 为什么要从 token 中减去前 7 个字符