I am trying to implement an OData service based on an entity framework model where authentication is provided by Azure Sql. I provide access to a row / column in the database.
I want this to be able to be called from LinqPad, Excel, etc. as a safe service.
I tried various schemes defined in the standard series, but even when returning 401, neither Excel nor LinqPad remembers the username and password I entered.
So, I thought I would make the username / password a request parameter (via SSL). But it turns out that this is illegal (OData requires a well-formed URL without request parameters).
So, I thought: why not use WebGet to embed the username and password in the URL, but I cannot get this to work with the original OData format in WCF:
<% @ServiceHost Language = "C #" Factory = "System.Data.Services.DataServiceHostFactory, System.Data.Services, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089" Service = "WebApplication5.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()
{
}
}
Has anyone really got OData to work where the username and password are passed into the source code?
source
share