【发布时间】:2011-09-20 11:42:35
【问题描述】:
我有一个 WCF 服务,它托管在 ASP.NET MVC Web 应用程序内的 IIS 7.0/7.5 中(通过使用带有 ServiceHost 指令的 .svc 文件)。我的配置中的安全设置如下所示:
<services>
<service name="MyServiceLib.MyService">
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="wsHttpBindingConfig"
contract="MyServiceLib.IMyService" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBindingConfig">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceCredentials>
<userNameAuthentication
userNamePasswordValidationMode="MembershipProvider"
membershipProviderName="AspNetSqlMembershipProvider"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
如您所见,我使用 SSL 来确保传输安全,然后使用用户名和密码对 ASP.NET 成员资格提供程序进行身份验证。到目前为止,这工作正常。
但我想将访问此服务的权限不仅限于经过身份验证的用户,而且仅限于具有特定角色且在其个人资料中设置了特定值的用户。 (我在 Web 应用程序中使用 SqlProfileProvider,每个用户都有一个配置了特定值的配置文件。)
是否可以通过配置设置来实现?如果没有,我是否可以在服务端创建某种自定义身份验证,允许我从传入消息中检索用户和密码,然后检查成员资格和角色并从配置文件存储中提取配置文件?我该怎么做?
【问题讨论】:
标签: wcf security asp.net-membership wcf-security