1

SOAP (wcf) を使用してサービスを構築しています。単一のパスワードとユーザー名を使用して、エンドポイントをもう少し安全にしたいと考えています。次の構成を追加しようとすると、Windows Azure で次のエラーがスローされます。

エラー: この構成セクションは、このパスでは使用できません。これは、セクションが親レベルでロックされている場合に発生します。ロックはデフォルト (overrideModeDefault="Deny") か、overrideMode="Deny" または従来の allowOverride="false" を使用したロケーション タグによって明示的に設定されます。

Linecode は次のとおりです。ローカリティをテストするときに IIS でこれを変更する必要がありましたが、どうやら Windows Azure プラットフォームでは調整できませんか?

私がやりたいのは、アクセスに独自のパスワードとユーザー名を使用することだけです。それは

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <customErrors mode="Off"/>
  </system.web>

  <system.serviceModel>

    <behaviors>
      <serviceBehaviors>
        <behavior name="credsBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata externalMetadataLocation="external metadata location" />

          <!-- 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="false" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="WCFServiceWebRole.CustomUserNameValidator, WCFServiceWebRole, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="ServiceEndpointBehavior">
          <schemaValidator validateRequest="True" validateReply="False">
            <schemas>
              <add location="schemalocation" />
            </schemas>
          </schemaValidator>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />

    <extensions>
      <behaviorExtensions>
        <add name="schemaValidator" type="WCFServiceWebRole.Validation.SchemaValidationBehaviorExtensionElement, WCFServiceWebRole, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
      </behaviorExtensions>
    </extensions>

    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpsBinding_CvServiceInterface" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" receiveTimeout="01:00:00" openTimeout="01:00:00" closeTimeout="01:00:00" sendTimeout="01:00:00">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

          <security mode="Transport">
              <transport clientCredentialType="Basic"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <services>
      <service name="WCFServiceWebRole.CvService" behaviorConfiguration="credsBehavior">
        <endpoint address="myendpoint" behaviorConfiguration="ServiceEndpointBehavior" binding="basicHttpBinding" bindingConfiguration="BasicHttpsBinding_CvServiceInterface" contract="ICvService" />
      </service>
    </services>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true" />

    <security>
      <authentication>
        <basicAuthentication enabled="true"/>
      </authentication>
    </security>
  </system.webServer>
</configuration>

<!--<system.webServer>
  <security>
    <authentication>
      <anonymousAuthentication enabled="false" />
      <basicAuthentication enabled="true" />
    </authentication>
  </security>
</system.webServer>-->

ジェローン

4

2 に答える 2

1

基本認証は、Windows Azure Web ロールでは既定では使用できません。

ここに画像の説明を入力

2 つの起動スクリプトを作成する必要があります。

基本認証をインストールする Powershell スクリプト

Import-Module ServerManager
Add-WindowsFeature Web-Basic-Auth

注: これには、Windows Server 2008 R2 に含まれている PowerShell 2.0 が必要です (Windows Server 2008 R2を取得するには、 osFamilyを 2 に設定する必要があります: http://msdn.microsoft.com/en-us/library/windowsazure/ ee758710.aspx )

基本認証を有効にするバットファイル

%windir%\system32\inetsrv\appcmd set config /section:basicAuthentication /enabled:true  

質問

なぜ基本認証が必要なのですか? 間違っている場合は訂正してください。ただし、WCF のユーザー名/パスワード認証は IIS がなくても機能するはずなので、なぜ基本認証が必要なのかわかりません。

于 2012-04-13T11:33:40.790 に答える
1

Sandrino が述べたように、カスタムのユーザー名とパスワードで承認と認証を取得するために basicauth は必要ありません。

それ以外の:

<security mode="Transport">
<transport clientCredentialType="Basic"/>
</security>

私がしなければなりませんでした:

  <security mode="TransportWithMessageCredential">
    <transport clientCredentialType="None"/>
    <message clientCredentialType="UserName" />
  </security>

クライアント側:

    ServiceReference1.CvServiceInterfaceClient cl = new ServiceReference1.CvServiceInterfaceClient();
    ClientCredentials creds = new ClientCredentials();

    creds.UserName.UserName = "username";
    creds.UserName.Password = "password";
    var defaultCredentials = cl.Endpoint.Behaviors.Find<ClientCredentials>();
    cl.Endpoint.Behaviors.Remove(defaultCredentials);
    cl.Endpoint.Behaviors.Add(creds);

ジェローン

于 2012-04-17T20:12:04.280 に答える