具有 Azure Active Directory 身份验证的 Azure WCF 服务 [英] Azure WCF Service with Azure Active Directory Authentication

查看:30
本文介绍了具有 Azure Active Directory 身份验证的 Azure WCF 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题似乎与这里的其他儿子相似,但我已经尝试过这里发布的答案:使用 Azure ACS 2.0 保护 WCF 4.5 服务

I know this question seems similar to other son here, but I have tried the answers posted Here: Securing WCF 4.5 service using Azure ACS 2.0

这里:Azure 上 WCF REST/HTML 服务的联合身份验证(单点登录)

Ans 似乎都不相关.

Ans neither seem to be relevant.

这是我目前所拥有的.

  • 具有各种辅助角色的 Azure 云服务,以及具有 REST 和 SOAP 端点的 WCF Web 角色
  • 一个有几个用户的天蓝色 Active Directory 帐户
  • ACS 命名空间.

WCF 服务将由几个不同的公司使用,但除此之外的公司已关闭.我们选择 azure Active Directory 为 wcf 服务和其他应用程序提供 SSO.

The WCF service will be used by a couple different companies but other than that closed off. We chose azure active directory to provide SSO for the wcf service and other apps.

这是我想做的:

  • 使用 WCF 服务为每个公司创建用户/密码Azure Active Directory.
  • 只允许拥有有效用户名和密码对的公司获取访问令牌
  • 让每家公司都使用他们的令牌来访问 WCF 方法.

我认为这并不难完成,但那里的所有教程似乎都是针对带有控制台应用程序的 IIS 托管或自托管服务.

I didn't think this would be that hard to accomplish, but all the tutorials out there seem to be for IIS hosted or self hosted services with a console application.

到目前为止我做了什么:

What I have done so far:

  • 将 WCF 服务作为集成应用添加到 azure Active Directory 中
  • 在 ACS 中创建了一个名为 testAAD 的新身份提供程序,并将集成应用程序中的 WS-Federation 元数据添加到该提供程序中
  • 添加了一个使用新创建的 testAAD 身份提供者的依赖方应用程序
  • 添加了一个具有传递规则的规则组,该规则使用 testAAD 身份提供程序和默认设置.

请参阅选项 1此处了解更多详情.我需要知道我所做的是否接近正确,如果是,我如何让 WCFservice 开始使用这些设置.

See option 1 here for more details. I need to know if what I did was anywhere close to correct, and if it was, how do I get the WCFservice to start using those settings.

其他信息:

  • WIF 4.5
  • VS2012 专业版
  • C#

任何相关的教程链接或一般建议都会很棒.提前致谢.

Any relevant tutorial links or general advice would be great. Thanks in advance.

更新:只是为了添加更多信息,许多不同的网站正在发布 WCF 服务.我们的每个客户都将从他们自己的 Web 表单中收集数据,然后使用 c# 代码添加服务引用,或者如果他们使用 php,则通过 curl 之类的方式将数据发布到 url.该服务有休息和肥皂端点.例如,他们会将 XML 或 SOAP 请求发送到 mynamespace.cloudapp.net/myservice.svc/servicemethod.我希望他们通过该请求发送他们的用户名和密码,并在实际的 WCF 方法中验证这些凭据,或者让他们请求一个身份验证令牌,然后在他们的请求中发送该身份验证令牌.

Update: Just to add more info, the WCF service is being posted to by a number of different websites. Each of our customers will collect data from their own web forms, and then either add a service reference using c# code, or post the data to a url via something like curl if they are using php. The Service has both rest and soap endpoints. So for example, they would send an XML or SOAP request to mynamespace.cloudapp.net/myservice.svc/servicemethod. I am either looking to have them send their username and password with that request and validate those credentials in the actual WCF Method, or have them request an authentication token, and then send that authentication token with their request.

更新 2我想我找到了丢失的部分.为了将活动目录用作身份提供者,我似乎需要设置一个 ADFS 服务器.我曾以为 ADFS 服务器已经使用 azure Active Directory 帐户设置,但显然不是这样?没有 ADFS 服务器有没有办法做到这一点?

Update 2 I think I found the missing piece. In order to use active directory as an identity provider, it looks like I need to set up an ADFS server. I had thought that the ADFS server was set up already with the azure active directory account, but apparently thats not the case? Is there any way to do this without an ADFS server?

推荐答案

您没有涉及的主要问题是 这些公司将如何使用 WCF 服务?.通过您的门户网站,还是通过富客户端(例如 WinForms/WPF)?

The main question you haven't covered is how will these companies use that WCF service?. Via your web portal, or via rich client (such as WinForms / WPF)?

如果是富客户端,可以看看这篇博文?它向您展示了如何使用令牌保护 WCF 服务并从 WPF 应用程序访问该服务.

If it is rich client, you can take a look at this blog post? It shows you how to secure WCF service with token and access that service from a WPF application.

如果您打算只允许通过您的门户网站访问 WCF 服务,那么情况就有些不同了.您可以先通过 Azure AD 保护您的门户并获取用户的令牌.然后使用该令牌对 WCF 进行身份验证.

If you plan to only allow access to the WCF service via your web portal, then picture is a bit different. You can first protect your portal by Azure AD and get user's token. Then use that token to authenticate against the WCF.

但在真正的 Web 场景中,调用服务的 client 实际上是 您的 Web 服务器.如果是这种情况,我将只使用 Azure AD 保护我的 Web 门户.然后用一个访问令牌保护我的 WCF.我可以从 Azure AD 访问控制中的服务标识获取该令牌.并将此服务令牌"作为来自我的 web 服务器 的每个 WCF 调用的一部分提供.为了增加审计(和合规性),我还将发送原始用户令牌,以跟踪谁访问了什么以及何时访问.

But in a truly web scenario, the client that will make calls to the service is actually your web server. If this is the case, I will just protect my web portal with Azure AD. Then protect my WCF with a single access token. I can get that token from a Service Identity in my Azure AD Access Control. And provide this "Service Token" as part of each WCF call from my web server. For added audit (and compliance) I will also send the original user token, to keep track of who accessed what and when.

这篇关于具有 Azure Active Directory 身份验证的 Azure WCF 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆