Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How-To Deal with WCF Authentication for Both SilverLight 4 and WPF Application

I'm looking for advice in order to deal with WCF Authentication for an application targetting both SilverLight and WPF client interface.

EDIT : Actually, the authentication mode i need is Username/Password combinaison.

In addition, in the future the application should be able to work in full-standalone mode (both client (WPF) and server on the same computer within the same application). So should i don't use WCF in that case ?

EDIT : Another addition, in the future again the application should be able to work in local network client-server mode (but without IIS), like a game. So should i don't use WCF in that case to ? Or any other option ?

like image 489
Yoann. B Avatar asked Feb 04 '11 15:02

Yoann. B


1 Answers

You can implement your own validator by inheriting from the UserNamePasswordValidator and setting the customUserNamePasswordValidatorType in your behavior configuration like this:

<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 into the ClientCredentials.UserName.UserName/Password property of your service.

like image 78
GaussZ Avatar answered Oct 04 '22 23:10

GaussZ