开发者

OData - Data Service Simple Authentication

开发者 https://www.devze.com 2023-01-11 18:08 出处:网络
I would like to add simple authentication to Data Services, for now only to restrict access for particular applications by simple token.

I would like to add simple authentication to Data Services, for now only to restrict access for particular applications by simple token.

I don't 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 it all demands a loooot of work. Most of all creating custom IHttpModule. There should be more simple solution.

I know that when I create 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 implementation of custom IHttpModule)?

I thought that I can use something in class that is implementation of Data Service for example:

protected override void OnStartProcessingRequest(ProcessRequestArgs args)
{
 string cred = args.OperationContext.AbsoluteRequestUri.UserInfo;
}

I'm not familiar with UserInfo but description for it stands "Gets the user name, password, ...)

So I have two main questions:

  1. Where can I read Credentials included by typing ent.Credentials = new NetworkCredential("token", "zx5as9vxc5sa9h0vb6523cv56");

  2. Where can I (if I can) set UserInfo on the client app and use it in OnStartProcessingRequest method.

Regards, Daniel Skowroński


There's a series of post about authentication and WCF Data Services (which is the .NET implementation of the OData protocol): http://blogs.msdn.com/b/astoriateam/archive/tags/authentication/

You should be able to find lot more information there (including code samples).

0

精彩评论

暂无评论...
验证码 换一张
取 消