【发布时间】:2010-11-15 01:50:15
【问题描述】:
我一直在尝试基于由 Sql Azure 提供身份验证的实体框架模型来实现 OData 服务。我在数据库中提供行/列访问。
我希望能够从 LinqPad、Excel 等中调用它作为安全服务。
我尝试了standard series 中定义的各种方案,但即使返回 401,Excel 或 LinqPad 都不会调用我输入的用户名和密码。
所以,我想我会将用户名/密码设置为查询参数(通过 SSL)。但事实证明这也是非法的(OData 需要格式正确且没有查询参数的 URL)。
然后我想,为什么不使用 WebGet 在 URL 中嵌入用户名和密码,但我无法使用 WCF 中的 OData 源格式:
public class OData : DataService< MyEntities >
{
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
protected override MyEntities CreateDataSource()
{
// create the OData source with the user name and password here
}
}
有没有人真正让 OData 在用户名和密码被传递到源中的情况下工作?
【问题讨论】:
标签: wcf authentication odata dataservice