0
我有一個WCF服務項目,我已經通過遵循guidelines here實現了自定義基本驗證,並且所有工作都很好!但是,我無法找到是否有方法拒絕未經身份驗證的用戶訪問僅限特定的端點。WCF拒絕某些端點上未經驗證的用戶
在我的項目中,我有大約5個端點,只希望用戶對其中的幾個進行身份驗證。其他人,我想允許匿名訪問。
我的web.config(片段)是這樣的:
<system.web>
<customErrors mode="Off"/>
<authentication mode="None"/>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
<httpModules>
<add name="CustomBasicAuthentication" type="WebServices.Auth.CustomBasicAuthenticationModule, WebServices"/>
</httpModules>
<authorization>
<deny users="?"/>
</authorization>
<membership defaultProvider="defaultProvider">
<providers>
<add name="defaultProvider" type="WebServices.Auth.WSMembershipProvider, WebServices"/>
</providers>
</membership>
</system.web>
端點是相當普通的,例如:
<service name="WebServices.Distance" behaviorConfiguration="defaultBehavior">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="defaultBinding" contract="WebServices.IDistance" behaviorConfiguration="rest" />
</service>
.... more endpoints below here ....
所以不是擊中所有端點的,我可以說,拒絕未經認證端點#1的用戶(或名稱或其他)。
我希望這是有道理的。如果沒有,請隨時嗤之以鼻。 :)