J'ai créé un simple service WCF REST que j'ai l'intention de consommer depuis une application iPhone. Le service fonctionne bien mais maintenant je voudrais le sécuriser.Sécurisation du service WCF REST pour une utilisation avec l'application iPhone
Dans mon environnement de test (IIS sous Windows 7), j'ai déjà configuré un certificat auto-signé en utilisant makecert.exe.
J'ai également surchargé la méthode validate() afin que je puisse utiliser un mot de passe personnalisé & (puisque l'authentification Windows est hors de question).
Maintenant, je suis bloqué pendant plus de deux jours pour comprendre comment configurer tout pour que ça fonctionne.
Mon objectif est maintenant de pouvoir faire une simple requête GET via le navigateur, quelque chose comme:
https://localhost/testservice/service1.svc/sayHello
Quand cela fonctionnera, je vais continuer à tous les trucs liés à l'iPhone.
Toute aide/exemple sera grandement apprécié!
Voici mon web.config:
<system.serviceModel>
<services>
<service name="IphoneWcf.Service1" behaviorConfiguration="IphoneWcf.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="webBehavior" contract="IphoneWcf.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> -->
<host>
<baseAddresses>
<add baseAddress="https://localhost/iphonewcf" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="IphoneWcf.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="false" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="webBinding">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
Merci à l'avance!
Presque là .. Je ne peux pas utiliser le condensé, car ma machine de test ne fait partie d'aucun domaine. Donc, pour commencer, j'utilise une authentification de base. Après avoir entré le nom d'utilisateur/mot de passe, j'obtiens une erreur "ressource non trouvée" –
En fait, je ne savais pas que IIS ne peut authentifier les utilisateurs digest que par rapport à un répertoire de domaine. Je suppose que je pensais aux modules http du fournisseur d'authentification ASP.Net, comme dans http://msdn.microsoft.com/en-us/library/bb386455.aspx. Où obtenez-vous l'erreur 'resource not found'? –
Lorsque j'effectue une requête GET dans Internet Explorer pour l'URL suivante: https: //localhost/testservice/service1.svc/sayHello Je reçois un message demandant un nom d'utilisateur et un mot de passe. Après avoir fourni le nom d'utilisateur et mot de passe associé à mon compte Windows - juste là je reçois la page ne peut pas être trouvé erreur –