开发者

Authenticate every call in WCF

开发者 https://www.devze.com 2022-12-10 03:58 出处:网络
I have a silverlight application that calls my wcf services so its a basichttpbinding. and we use forms authen开发者_如何学编程tication. I want to do a authentication check for every call that I recei

I have a silverlight application that calls my wcf services so its a basichttpbinding. and we use forms authen开发者_如何学编程tication. I want to do a authentication check for every call that I receive except for the "AuthenticationService" (as this is the method which will do the basic authentication for login) so after user logs in and tries to call other services then I want this authentication check to be performed so that only authenticated users will be granted access to them. Is there is any best way to implement this... ???

After searching through various blogs, I came to know that we can use HttpContext.Current....IsAuthenticated property to check if user is authenticated or not. But my question is how secure and valid is HttpContext? Can we rely on that? or should we be using OperationContext? (and yes aspnetcompatability is set to true).

Please suggest!!

Thanks in advance

Sai


If you're hosting your WCF services in the ASP.NET runtime (i.e. <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />) then you should absolutely be able to rely on ASP.NET's security system.

Check out this answer I gave to another question on how to leverage ASP.NET security for ASMX services. The same approach can be used to secure a WCF service as long as you're enabling ASP.NET as your service hosting environment.


Here are some articles that may help:

http://msdn.microsoft.com/en-us/library/dd560702(VS.95).aspx http://silverlightuk.blogspot.com/2008/03/silverlight-wcf-and-aspnet.html http://smehrozalam.wordpress.com/2009/01/07/securing-silverlight-application-and-wcf-service-using-aspnet-authentication-techniques/

Short answer is you can use the asp.net controls to do authorization, or use HttpContext.Current directly (as long as AspNetCompatMode is enabled).

0

精彩评论

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