【问题标题】:Is WCF Service EntitySetRights.AllRead Secure?WCF 服务 EntitySetRights.AllRead 是否安全?
【发布时间】:2013-09-26 16:13:47
【问题描述】:

我在 MyDataService.svc.cs 中有以下代码(这是 DevExpress 的一个示例):

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 上看到此信息。如果不是这样,有人可以填补我面临的概念空白。谢谢!

【问题讨论】:

    标签: security authentication devexpress odata wcf-security


    【解决方案1】:

    您是正确的,查询时将返回所有实体 - AllRead 只是不允许插入更新和删除。

    您将需要使用 Query Interceptor 添加您的逻辑,以将用户限制在他们有权查看的数据集,例如向查询添加检查用户 ID。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-13
      • 1970-01-01
      • 2011-08-26
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      相关资源
      最近更新 更多