none
WCF аутентификация. При вводе неправильного пароля клиент постоянно в цикле пытается аутентифицироваться. RRS feed

  • Общие обсуждения

  • У меня приложение клиент должно проходить аутентификацию на сервисе. Настроил. Все нормально проходит если пароль вводить правильно. 
    Если же пароль ввести не правильно, то клиент начинает упорно пытаться пройти аутентификацию. Хотя и на стороне сервера постоянно ему дается отбой. При этом приложение зависает. Ну почему зависает все ясно. Не ясно почему оно упорно пытается пройти аутентификацию. В логах я вижу, постоянную попытку пройти аутентификацию, хотя в ответ клиент получает отбой. В моем клиенте цикла явно нету. Кстати один момент. Попытки аутентификации продолжаются упорно пока не сработает ограничение таймаута на стороне клиента receiveTimeout="00:10:00" sendTimeout="00:10:00". 
    ОСНОВНОЙ ВОПРОС: КАК УКАЗАТЬ КЛИЕНТУ, ЧТО ЕСЛИ ОДИН РАЗ ОН  ПОЛУЧИЛ ОТБОЙ, НЕ ПЫТАТЬСЯ ПРОЙТИ АУТЕНТИФИКАЦИЮ ВТОРОЙ РАЗ.
    Ниже представлен конфиг сервиса:

    <?xml version="1.0" encoding="utf-8"?>
    <!--
        Note: As an alternative to hand editing this file you can use the 
        web admin tool to configure settings for your application. Use
        the Website->Asp.Net Configuration option in Visual Studio.
        A full list of settings and comments can be found in 
        machine.config.comments usually located in 
        \Windows\Microsoft.Net\Framework\v2.x\Config 
    -->
    <configuration>   
        
      <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
              <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
              <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
              <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
              <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
            </sectionGroup>
          </sectionGroup>
        </sectionGroup>
      </configSections>
      <connectionStrings></connectionStrings>
      <appSettings>
        <add key="SSJKU" value="2,100" />
        <add key="sqlLogPath" value="c:\\log\\" />
        <add key="commonLogPath" value="c:\\log\\" />
        <add key="GPCConnectionString" value="Data Source=DEVSRV\SQL2005;Initial Catalog=GRC;User ID=sa;Password=tester" />
        <add key="provider" value="System.Data.SqlClient"/>
        <add key="PersonalAccountObjectParam" value=""/>
        <add key="PersonalAccountContractParam" value=""/>
        <add key="PersonalAccountTarifParam" value=""/>
      </appSettings>
      <system.web>
        <!--
                Set compilation debug="true" to insert debugging 
                symbols into the compiled page. Because this 
                affects performance, set this value to true only 
                during development.
            -->
        <compilation debug="true">
          <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </assemblies>
        </compilation>
        <!--
                The <authentication> section enables configuration 
                of the security authentication mode used by 
                ASP.NET to identify an incoming user. 
            -->
        <membership defaultProvider="DBMembershipProvider" userIsOnlineTimeWindow="10">
          <providers>
            <clear />
            <add name="DBMembershipProvider" type="GPCService.DBMembershipProvider" connectionStringName="GPCDBConnectionString" applicationName="SecuritySampleApp" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" />
          </providers>
        </membership>
        <authentication mode="Windows" />
        <!--
                The <customErrors> section enables configuration 
                of what to do if/when an unhandled error occurs 
                during the execution of a request. Specifically, 
                it enables developers to configure html error pages 
                to be displayed in place of a error stack trace.
    
            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
        <pages>
          <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </controls>
        </pages>
        <httpHandlers>
          <remove verb="*" path="*.asmx" />
          <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
        </httpHandlers>
        <httpModules>
          <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </httpModules>
      </system.web>
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="WarnAsError" value="false" />
          </compiler>
        </compilers>
      </system.codedom>
      <!--
            The system.webServer section is required for running ASP.NET AJAX under Internet
            Information Services 7.0.  It is not necessary for previous version of IIS.
        -->
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules>
          <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </modules>
        <handlers>
          <remove name="WebServiceHandlerFactory-Integrated" />
          <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        </handlers>
      </system.webServer>
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <services>
          <service behaviorConfiguration="GPCService.GPCServiceBehavior" name="GPCService.GPCService">
            <endpoint address="" binding="wsHttpBinding" bindingConfiguration="MembershipBinding" contract="GPCService.IGPCService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="GPCService.GPCServiceBehavior">
              <serviceCredentials>            
                <serviceCertificate findValue="MyServerCert" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My" />
                <!--
                <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="DBMembershipProvider" />
                -->            
                <userNameAuthentication cacheLogonTokens="true" maxCachedLogonTokens="10" cachedLogonTokenLifetime="10:00:00"  userNamePasswordValidationMode="Custom"  customUserNamePasswordValidatorType="GPCService.MyUserNamePasswordValidator,GPCService" />
              </serviceCredentials>
              <serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true"  />
              <serviceSecurityAudit messageAuthenticationAuditLevel="SuccessOrFailure" serviceAuthorizationAuditLevel="SuccessOrFailure" auditLogLocation="Application" />
              <dataContractSerializer maxItemsInObjectGraph="999999" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
          <wsHttpBinding>
            <binding name="MembershipBinding" maxReceivedMessageSize="20000000" maxBufferPoolSize="20000000" allowCookies="true">          
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <reliableSession enabled="true" inactivityTimeout="00:30:00" ordered="true" />
              <security mode="Message" >
                <message clientCredentialType="UserName"  />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
      </system.serviceModel>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel" switchValue="Error">          
            <listeners>
              <add name="traceListener" traceOutputOptions="LogicalOperationStack"
                  type="System.Diagnostics.TextWriterTraceListener"
                  initializeData= "c:\log\Traces.svclog" />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>
    </configuration>
    


    ****************************************************************
    А это конфиг клиента

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections></configSections>
      <connectionStrings>
      </connectionStrings>
      <appSettings>
        <add key="checkUpdateOnStart" value="                 " />
        <add key="UnzipProgram" value=".\unzip.exe" />
        <add key="urlUnzipInServer" value="http://localhost:1230/Output/unzip.exe" />
        <add key="urlFile" value="http://localhost:1230/Output/GPCClientSetup.zip" />
        <add key="urlTxt" value="http://localhost:1230/Output/Version.txt" />
        <add key="CertName" value="CN=MyServerCert" />
        <add key="CredentialsEncryption" value="2K*8zOmk" />
        <add key="logPath" value="C:\Program Files\Bevolex\GPC Kaspiysk\" />
        <add key="ClientSettingsProvider.ServiceUri" value="" />
      </appSettings>  
      <system.serviceModel>    
        <bindings>      
          <wsHttpBinding>        
            <binding name="WSHttpBinding_IGPCService" closeTimeout="00:01:00" openTimeout="00:02:00" receiveTimeout="00:10:00" 
                     sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
                     maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" 
                     textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="true" >
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"  maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <reliableSession ordered="true" inactivityTimeout="00:01:00" enabled="true"  />          
              <security mode="Message">
                <!--<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""  />-->
                <message  clientCredentialType="UserName" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"  />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost:1230/GPCService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IGPCService" contract="GPCService.IGPCService" name="WSHttpBinding_IGPCService" behaviorConfiguration="CertBehavior">
            <identity>
              <dns value="MyServerCert" />
            </identity>
          </endpoint>
        </client>
        <behaviors>
          <endpointBehaviors>
            <behavior name="CertBehavior">
              <clientCredentials>
                <serviceCertificate>
                  <authentication certificateValidationMode="Custom" customCertificateValidatorType="PresenterLayer.X509Validator,PresenterLayer" />              
                </serviceCertificate>
              </clientCredentials>
              <dataContractSerializer maxItemsInObjectGraph="999999" />
            </behavior>
          </endpointBehaviors>
        </behaviors>
      </system.serviceModel>
      <system.web>
      </system.web>
    </configuration>
    

    • Перемещено I.Vorontsov 2 ноября 2009 г. 8:18 Более соответствующая тематика (От:Visual C#)
    • Изменен тип I.Vorontsov 21 марта 2010 г. 16:40
    1 ноября 2009 г. 20:05

Все ответы