定制"基本"身份验证我的WCF服务。 REST和RIA。可能? [英] Custom "Basic" Authentication for my WCF services. REST and RIA. Possible?

查看:170
本文介绍了定制"基本"身份验证我的WCF服务。 REST和RIA。可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器端包含WCF4 REST服务,我要为我的未来SL4应用程序中添加RIA服务。目前,我在做基本身份验证是这样的:

My server side contains WCF4 REST services and I'm going to add RIA services for my future SL4 application. Currently I'm doing Basic authentication like this:

var auth = HttpContext.Current.Request.Headers.GetValues("Authorization");

和等..你的想法。我把这个在每次请求。如果没有头present否则我无法验证UN /密码 - 我这样做:

And so on.. You get the idea.. I call this on every request. If header not present or I can't validate UN/Password - I do this:

outgoingResponse.Headers.Add("WWW-Authenticate: Basic realm=\"Secure Area\"");

这让我这么远,但我重构我的服务器端。对于链接服务实现的IoC。创建了自定义的ServiceHost,ServiceHostFactory,InstanceProvider,一切都很好。

That got me by so far but I'm refactoring my server side. Implementing IoC for linked services. Created custom ServiceHost, ServiceHostFactory, InstanceProvider and all is well.

现在我需要确定如何正确处理身份验证和授权使用WCF,所以我不必手工检查头。我有我的自定义的MembershipProvider所以有一些方法得到的UN / PW来处理。

Now I need to figure how to properly handle authentication and authorization with WCF so I don't have to manually inspect headers. I do have my custom MembershipProvider so there have to be some method that get's UN/PW to process.

任何指针?我看着 HTTP://www.$c$cproject.com/KB/ WCF / BasicAuthWCFRest.aspx 但它使用RequestInterceptor,这是不具备的WCF4。我发现ServiceAuthenticationManager和ServiceAuthorizationManager但提供了有关如何code和电线那些没有样品。

Any pointers? I looked at http://www.codeproject.com/KB/WCF/BasicAuthWCFRest.aspx but it uses RequestInterceptor and it is not available in WCF4. I found ServiceAuthenticationManager and ServiceAuthorizationManager but there is no samples available on how to code and wire those..

任何人都可以建议我应该走哪条路?

Can anybody suggest which way I should go?

推荐答案

尝试使用此自定义HTTP模块。这将增加新的认证方式为IIS,它可以让你使用自定义凭据验证。

Try to use this custom HTTP module. It will add new authentication mode to IIS and it will allow you using custom credentials validation.

这篇关于定制"基本"身份验证我的WCF服务。 REST和RIA。可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆