简体   繁体   English

IIS中的WCF:WCF执行的基本授权

[英]WCF in IIS: basic authorization performed by WCF

I am hostin WCF service in IIS and I am using basic authorization. 我在IIS中托管WCF服务,并且正在使用基本授权。 As IIS is performing the authorization, my WCF service has no ability to tell if particular user is allowed or not. 当IIS执行授权时,我的WCF服务无法判断是否允许特定用户。 Unfortunately, I have to support a list of enabled user names. 不幸的是,我必须支持已启用用户名的列表。 The service and the metadata must be available only for the users on the list, and not the others. 该服务和元数据必须仅对列表中的用户可用,而对其他用户不可用。 How is this possible, using only basic authorization? 仅使用基本授权怎么办? Message authorization is not an option, as I have no control on the service consumers. 消息授权不是一种选择,因为我无法控制服务使用者。

Clarification: I can assign Windows users to the service, restricting access to specific group. 澄清:我可以将Windows用户分配给该服务,从而限制对特定组的访问。 What I want to achieve is to allow the service programatically restrict access to specific users. 我要实现的是允许该服务以编程方式限制对特定用户的访问。 The naive approach using UserNamePasswordValidator can not be used, since IIS is performing the authentication on its own. 由于IIS自行执行身份验证,因此无法使用使用UserNamePasswordValidator的幼稚方法。

Seems to me like you might be confusing two separate concerns: 在我看来,您可能会混淆两个独立的问题:

When using transport security with WCF in your case, IIS will do the Authentication . 在您的情况下将传输安全性与WCF一起使用时,IIS将执行Authentication This is only validating that the specified username/password is a valid combination in the authentication context (local machine or domain). 这仅验证指定的用户名/密码在身份验证上下文(本地计算机或域)中是否为有效组合。

However, what you want to do is use Authorization to control if the authenticated user has access to your service or not. 但是,您要做的是使用“ 授权”来控制通过身份验证的用户是否有权访问您的服务。 This is a separate concern where WCF does have control over this. 这是一个单独的关注,其中WCF 确实有在这个控制。 What you want to do is setup an authorization policy that grants access to the service to only those users you want. 您要做的是设置一个授权策略,该策略仅向您想要的用户授予对服务的访问权限。

By default, this would be done based on Windows Group membership, but if that is not a good fit for your scenario, you can customize how that happens at the WCF level, for example using the ASP.NET Role Membership provider, or even with a custom role provider. 默认情况下,这将基于Windows组成员身份来完成,但是如果这不太适合您的方案,则可以自定义在WCF级别的发生方式,例如使用ASP.NET角色成员资格提供程序,甚至使用自定义角色提供者。

The following two articles should point you in the right direction: 以下两篇文章应为您指明正确的方向:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM