Tor*_*ups 24 security rest wcf web-services
我正在寻找一个允许在WCF中使用RESTful服务的配置文件,但我仍然希望能够"利用"成员资格提供程序进行用户名/密码身份验证.
以下是使用basicHttp绑定或wsHttp w/out WS Security的当前配置的一部分,这将如何改变基于REST的服务?
    <bindings>
        <wsHttpBinding>
            <binding name="wsHttp">
                <security mode="TransportWithMessageCredential">
                    <transport/>
                    <message clientCredentialType="UserName" negotiateServiceCredential="false" establishSecurityContext="false"/>
                </security>
            </binding>
        </wsHttpBinding>
        <basicHttpBinding>
            <binding name="basicHttp">
                <security mode="TransportWithMessageCredential">
                    <transport/>
                    <message clientCredentialType="UserName"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="NorthwindBehavior">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceAuthorization principalPermissionMode="UseAspNetRoles"/>
                <serviceCredentials>
                    <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"/>
                </serviceCredentials>
            </behavior>
        </serviceBehaviors>
    </behaviors>
更新 01/23/2012
自从我写了这个问题以来,我发现了一种更好的方法来保护 REST(如野外 Web 服务)。当我第一次听说它时,它听起来很复杂,但这个想法很简单,并且遍布整个网络,用于网络服务和其他安全通信。
它需要使用公钥/私钥。
1.) 端点的每个用户(客户)都需要注册您的 REST Web 服务
2.) 用户的每个请求都需要生成一个哈希来对请求进行签名
3.) 服务器端点(您的 REST 方法)将需要使用与客户端上使用的相同输入来生成哈希。此步骤将证明客户端和服务器都知道与随请求传递的公钥相匹配的私钥。(这反过来意味着发送请求的用户是合法的,因为没有其他人知道私钥)
a.) 通过请求期间传递的公钥查找客户的私钥
b.) 获取其他参数(时间戳和编码的有效负载)以及您在上一步中找到的私钥,并使用相同的算法生成单向哈希(hmac 也是我在现实世界中看到的) )