开发者

WCF, ASP.NET Compatibility Mode and custom authentication using membership providers

I need help in following:)

To begin with I work on the large application, that has a WinForms client and server. Server in our case is the set of WCF services. There is one service that is responsible for authentication of users. The logic of authentication is custom and complex and authentication service uses different membership p开发者_开发问答roviders.

We want to protect the access to server services for non-authenticated users. The users must firstly authenticate and than use other services (users in this case are the other systems, services, WinForms client, etc.). On this basis, we decided to use the ASP.NET Url/File Authorization feature.

So, I set on the ASP.NET compatibility mode, allowed cookie in all binding configurations, added AspNetCompatibilityRequirements attribute to our services and added the followingconfigurations to config:

    <authentication mode="Forms">
      <forms cookieless="UseCookies">
        <credentials passwordFormat="Clear" />
      </forms>
    </authentication>

    <authorization>
       <deny users="?" />
    </authorization>

    ...

<location path="AuthenticationService.svc">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>

In the authenticate method of our authentication service I add the following code:

public AuthenticationResult AuthenticateUser(string username, string password)
{
    AuthenticationResult result = new AuthenticationResult();
    result = Authenticate(username, password);

    if (result.IsAuthenticated)
        FormsAuthentication.SetAuthCookie(username, true);

    return result;
}

Next, I wrote the following code:

var authClient = new AuthenticationServiceClient();
var result = authClient.AuthenticateUser("user", "password");
var otherClient = new OtherServiceClient();
var temp = otherClient.DoSomething();    

But after authentication I can't access to OtherServiceClient...

So, how can I share the call context between the WCF services calls? Could anybody provide some useful articles about this question?

Thanks in advance! Best regards.


You need to:

1) Enable sessions in WCF

2) Authenticate using WCF

3) Keep reusing your proxies instead of creating new ones.

This is useful: http://msdn.microsoft.com/en-us/library/ms733040.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜