How to handle WCF authentication for SilverLight 4 and WPF applications

I am looking for advice to deal with WCF authentication for an application targeting the SilverLight and WPF client interfaces.

EDIT: Actually, I need authentication mode: username / password.

In addition, in the future, the application should work in full screen mode (both the client (WPF) and the server on the same computer in the same application). So should I use WCF in this case?

EDIT: Another addition, in the future again the application should work in the client-server mode of the local network (but without IIS), as in the game. So should I not use WCF in this case? Or any other option?

+7
source share
5 answers

You can implement your own validator by inheriting from UserNamePasswordValidator and setting customUserNamePasswordValidatorType in your behavior configuration as follows:

<behaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyNamespace.MyValidator, MyNamespace" /> </serviceCredentials> </behavior> </serviceBehaviors> </behaviors> 

On the client side, you can set the username / password combination in the ClientCredentials.UserName.UserName / Password property of your service.

+1
source

Check out this solution using AuthenticationService. I like it and decided to use it for a three-platform application (web / SL / WPF)

http://msdn.microsoft.com/en-us/library/system.web.applicationservices.authenticationservice.aspx

Follow the links to implement the examples.

That way, you can rely on the classic ASP.NET MemberhipProvider implementation (even in a standalone client).

0
source

IIS is not required to host the WCF service. Take a look at the link for various hosting options. WCF also allows communication over various protocols. Look at the link for a summary of hosting options based on the operating platform and communication protocol.

0
source

There are several methods that can be used to authenticate WCF services (X509 certificates, tokens, username / password, and Windows authentication. Choosing the right credential type.

Assuming (since you are using silverlight and WPF) that the configuration is in a Windows environment, you can use Windows authentication. To enable Windows authentication, follow these steps and host your service in IIS.

Hope this helps and good luck!

0
source

The advantage of using WCF is that if you want to open the service on a network or in the outside world, you can simply change / add some additional configurations without any changes in the code.

So, in your scenario, the presence of both the client and the server on the same machine or inside the network is absolutely normal, and the simple way is to have 2 endpoints that deal with your requirements on the same service.

You can manage with one endpoint, but using different endpoints with a different binding mechanism reduces your overhead during authentication. Example: when you are on the same machine, you can use the network: pipe or net: tcp binding When you are in a domain, you can use net: tcp or httpbinding.

Performance is different when using different bindings.

0
source

All Articles