I would like to add simple authentication to Data Services, so far only to restrict access to specific applications with a simple token.
I do not need domain authentication or forms authentication.
I read a lot about authentication here:
http://franssenden.wordpress.com/2010/06/14/custom-security-odata-service-wcf-data-services/
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/06/03/10482.aspx
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/01/15/10119.aspx
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/01/10/10100.aspx
Unfortunately, all this requires work. Most of all, the custom IHttpModule is created. There should be a simpler solution.
I know that when I create an object context on the client (WPF), I can add Credentials.
Uri uri = new Uri("http://localhost/myapp/odata.svc");
MyEntities ent= new MyEntities (uri);
ent.Credentials = new NetworkCredential("token", "zx5as9vxc5sa9h0vb6523cv56");
But where can I read them (without implementing a custom IHttpModule)?
I thought I could use something in the class, this is a Data Service implementation, for example:
protected override void OnStartProcessingRequest(ProcessRequestArgs args)
{
string cred = args.OperationContext.AbsoluteRequestUri.UserInfo;
}
I am not familiar with UserInfo, but the description for it is "Get user name, password, ...)
So, I have two main questions:
Where can I read the credentials included by entering ent.Credentials = new NetworkCredential ("token", "zx5as9vxc5sa9h0vb6523cv56");
Where can I (if I can) install UserInfo in a client application and use it in the OnStartProcessingRequest method.
Regards, Daniel Skourowski