IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Services Web Discussion :

WCF Authentification Form


Sujet :

Services Web

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2007
    Messages
    99
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Yonne (Bourgogne)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2007
    Messages : 99
    Par défaut WCF Authentification Form
    Bonjour,

    Ma question va sans doute paraître bête et la réponse est probablement très simple mais je sèche depuis déjà de trop nombreuses heures :'(.

    Dans mon service WCF, je souhaite utiliser le type d'authentification "Form" afin de gérer dans mon client la saisie d'un username et d'un password.

    Ayant une architecture "particulière", j'ai créé mon propre RoleProvider et mon propre MembershipProvider.
    J'ai impacté mon fichier de configuration afin de prendre en compte ces modifications et j'ai activité le mode "Form".

    Je lance mon client dans VS2010, ce dernier auto héberge mon service WCF et... paf le chien !

    Lorsque je regarde "ServiceSecurityContext.Current.AuthorizationContext.Properties..... je vois AuthentificationType = "NTLM" / Name = MaMachine\\MonCompteWindows

    Alors que sur le client :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
                _townServiceClient = new TownServiceClient();
                _townServiceClient.ClientCredentials.UserName.UserName = "Laurent";
                _townServiceClient.ClientCredentials.UserName.Password = "p@ssw0rd";
    Du coup, je viens de perdre beaucoup de temps là dessus : //

    Le fichier de configuration cotés serveur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    <?xml version="1.0"?>
    <configuration>
      <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <section name="Mcel.WcfServiceLibrary.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
      </configSections>
      <!-- Lors du déploiement du projet de bibliothèque du service, le contenu du fichier de configuration doit être ajouté au fichier app.config  
      de l'hôte. System.Configuration ne prend pas en charge les fichiers de configuration pour les bibliothèques. -->
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <bindings />
        <services>
          <service name="Mcel.WcfServiceLibrary.TownManagementService.TownService">
            <endpoint address="ws" binding="wsHttpBinding" contract="Mcel.WcfServiceLibrary.TownManagementService.ITownService">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- Pour éviter la divulgation des informations sur les métadonnées, 
              définissez la valeur ci-dessous sur false et supprimez le point de terminaison des métadonnées ci-dessus avant le déploiement -->
              <serviceMetadata httpGetEnabled="True" />
              <!-- Pour recevoir les détails d'exception des erreurs à des fins de débogage, 
              définissez la valeur ci-dessous sur true.  Définissez-la sur false avant le déploiement 
              pour éviter la divulgation des informations d'exception -->
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="McelRoleProvider" />          
              <serviceCredentials>            
                <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="McelMembershipProvider" />
              </serviceCredentials>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
      <system.web>
        <authentication mode="Forms"/>   
        <compilation debug="true" />
        <membership defaultProvider="McelMembershipProvider">
          <providers>
            <clear />
            <add name="McelMembershipProvider" type="Mcel.WcfServiceLibrary.Authentification.McelMembershipProvider, Mcel.WcfServiceLibrary" />
          </providers>
        </membership>
        <roleManager enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="McelRoleProvider">
          <providers>
            <clear />
            <add name="McelRoleProvider" type="Mcel.WcfServiceLibrary.Authentification.McelRoleProvider, Mcel.WcfServiceLibrary" />
          </providers>
        </roleManager>
      </system.web>
      <applicationSettings>
        <Mcel.WcfServiceLibrary.Properties.Settings>
          <setting name="MinRequiredPasswordLength" serializeAs="String">
            <value>6</value>
          </setting>
          <setting name="ApplicationName" serializeAs="String">
            <value>Mcel</value>
          </setting>
        </Mcel.WcfServiceLibrary.Properties.Settings>    
      </applicationSettings>
    </configuration>
    Le fichier généré cotés client :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
     
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <wsHttpBinding>
                    <binding name="WSHttpBinding_ITownService" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                        allowCookies="false">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <reliableSession ordered="true" inactivityTimeout="00:10:00"
                            enabled="false" />
                        <security mode="Message">
                            <transport clientCredentialType="Windows" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                                algorithmSuite="Default" />
                        </security>
                    </binding>
                </wsHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/ws"
                    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITownService"
                    contract="Service.Wcf.ITownService" name="WSHttpBinding_ITownService">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
            </client>
        </system.serviceModel>
    </configuration>
    Une idée ?

    Merci

  2. #2
    Rédacteur
    Avatar de Nathanael Marchand
    Homme Profil pro
    Expert .Net So@t
    Inscrit en
    Octobre 2008
    Messages
    3 615
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Expert .Net So@t
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2008
    Messages : 3 615
    Par défaut
    Ouép c'est normal! Ca se voit d'ailleurs coté client t'es en clientCredentialType="Windows".
    Pour remedier à ca, il faut que côté que côté serveur tu defnisses un binding dans la section bindings.
    http://msdn.microsoft.com/fr-fr/library/ms731362.aspx

    A y regarder de plus près je pense qu'il faut que tu sois en Username sur la securité message

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <bindings>
                <wsHttpBinding>
                    <binding name="WSHttpBinding_ITownService">
                        <security mode="Message">
                            <message clientCredentialType="UserName" negotiateServiceCredential="true"
                                algorithmSuite="Default" />
                        </security>
                    </binding>
                </wsHttpBinding>
            </bindings>

Discussions similaires

  1. Authentification = forms
    Par ylarvor dans le forum ASP.NET
    Réponses: 2
    Dernier message: 17/10/2007, 15h00
  2. Authentification Forms sans MOSS
    Par Fourmi4x dans le forum SharePoint
    Réponses: 1
    Dernier message: 20/09/2007, 13h41
  3. [C#] Sécurité: mode authentification form
    Par wayak3 dans le forum ASP.NET
    Réponses: 13
    Dernier message: 23/11/2005, 15h45
  4. [VB.NET] Authentification Forms RedirectFromLoginPage
    Par cosmos38240 dans le forum ASP.NET
    Réponses: 3
    Dernier message: 08/04/2005, 11h05
  5. [VB.NET] Authentification Form qui rate.
    Par Abalalojik dans le forum ASP.NET
    Réponses: 4
    Dernier message: 10/01/2005, 13h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo