2013-09-25 148 views
1

我里面MyDataService.svc.cs下面的代码(这是从DevExpress的一个例子):WCF服务EntitySetRights.AllRead安全吗?

namespace MyDataService { 

    [System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)] 

    [JSONPSupportBehavior] 
    public class DataService : DataService<TestDataEntities>, IServiceProvider { 
     public static void InitializeService(DataServiceConfiguration config) { 
      config.SetEntitySetAccessRule("*", EntitySetRights.AllRead); 
      config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V3; 
     } 

     public object GetService(Type serviceType) { 
      if (serviceType == typeof(IDataServiceStreamProvider)) { 
       return new ImageStreamProvider(); 
      } 
      return null; 
     } 

     protected override void OnStartProcessingRequest(ProcessRequestArgs args) { 
      CustomBasicAuth.Authenticate(HttpContext.Current); 
      if (HttpContext.Current.User == null) 
       throw new DataServiceException(401, "Invalid login or password"); 
      base.OnStartProcessingRequest(args); 
     } 
    } 
} 

因此,尽管这是将检查实体用户名和密码,如何安全是它那config.SetEntitySetAccessRule是设置为AllRead。是否有人能够在诸如www.website.com/MyDataService.svc/Customer(其中Customer是表格)的url上看到这些信息。如果不是这样,那么请填写我面临的概念差距。谢谢!

回答

1

所有实体在查询时都会返回 - AllRead不允许插入更新和删除。

您将需要使用Query Interceptor添加您的逻辑来限制用户访问他们有权查看的数据集,例如在查询中添加检查用户标识。