【发布时间】:2010-07-20 13:33:55
【问题描述】:
您好所有 DevExpress 开发人员! =)
我正在尝试远程驯服 Express Persistent Objects。
实际上,XPO 允许两种不同的方法 - 直接访问数据库,以及通过 WebService/WCF。
出于安全原因,我们选择了第二个选项。现在,WCF 封装了数据库访问,客户端必须对自己进行身份验证才能访问数据库。
该软件是一个文档管理系统。因此,它的主要数据库表(继承自 XpObject 的类)是“Documents”和“Users”。我们还有额外的表(XPO 类)“DocumentUserAccess”,它通过关联将用户和文档绑定在一起。客户端通过 XPCollections 检索数据。
即使客户端现在必须进行身份验证,我们也必须限制他们对某些文档的访问(而管理员应该有权访问所有文档)。
webservice 部分包含以下代码,使远程 XPO 访问成为可能:
Private Function Common_IDataStoreContract_ModifyData(ByVal ParamArray dmlStatements As ModificationStatement()) As ModificationResult Implements IDataStoreContract.ModifyData
Return wrappedDataStore.ModifyData(dmlStatements)
End Function
Private Function Common_IDataStoreContract_SelectData(ByVal ParamArray selects As SelectStatement()) As SelectedData Implements IDataStoreContract.SelectData
Dim data As SelectedData = wrappedDataStore.SelectData(selects)
Return data
End Function
限制对某些 TABLES 的访问非常容易:
For Each statement In dmlStatements
If Not UserCanAccessTable(OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name, statement.TableName) Then
Throw New Security.SecurityAccessDeniedException("You aren't allowed to modify this table.")
End If
Next
但是,我们不知道如何限制对某些 ROWS 的访问。
如上所示,客户端请求的所有条件和其他参数都可以在语句(DevExpress.XPO.DB.ModificationStatement 类)中访问。
同时,如何检查用户是否请求了特定的文档?客户端可以使用不同的标准来获取文档,而不仅仅是 OID 和名称。例如,客户端可以根据日期范围请求收集文档。
因此,在数据库请求执行之前,我们无法确定客户端将接收或修改哪些行,也无法检查他是否可以访问这些行。
任何帮助将不胜感激。
谢谢, 约翰
【问题讨论】:
标签: .net database wcf devexpress orm