ダイジェスト認証 <digestAuthentication>

概要

<digestAuthentication> 要素には、インターネット インフォメーション サービス (IIS) 7 ダイジェスト認証モジュールの構成設定が含まれています。 ダイジェスト認証を有効または無効にするようにこの要素を構成し、必要に応じてダイジェスト認証領域を指定できます。

ダイジェスト認証は基本認証ほど広く使用されていませんが、基本認証や Windows 認証よりも明確ないくつかの利点があります。 暗号化されていない通信手段で基本認証を使用する場合の主な欠点は、クライアントのユーザー名とパスワードが Base64 でエンコードされたプレーンテキスト メッセージとして送信されるため、悪意のあるユーザーが通信を傍受し、ユーザー名とパスワードを取得することが非常に簡単になることです。 Windows 認証では、さまざまなセキュリティ オプションによってこの問題が解決されますが、通常、Windows 認証はインターネット環境では機能しません。

ダイジェスト認証では、前述の両方の制限事項に次の方法で対処します。

  • 基本認証で使用されるプレーンテキスト方式とは異なり、ダイジェスト認証では、クライアントは通信チャネル経由でクライアントの情報のハッシュを送信するため、クライアントのユーザー名とパスワードはネットワーク経由で送信されません。
  • ダイジェスト認証はインターネット経由で適切に機能するため、ダイジェスト認証は Windows 認証よりもその環境に適しています。

Note

ダイジェスト認証では、クライアントのユーザー名とパスワードのみが保護されます。HTTP 通信の本文はプレーンテキストのままです。 通信の本文をセキュリティで保護するには、Secure Sockets Layer (SSL) を使用する必要があります。

互換性

バージョン メモ
IIS 10.0 <digestAuthentication> 要素は、IIS 10.0 では変更されませんでした。
IIS 8.5 <digestAuthentication> 要素は、IIS 8.5 では変更されませんでした。
IIS 8.0 <digestAuthentication> 要素は IIS 8.0 では変更されませんでした。
IIS 7.5 <digestAuthentication> 要素は、IIS 7.5 では変更されませんでした。
IIS 7.0 <digestAuthentication> 要素が IIS 7.0 で導入されました。
IIS 6.0 <digestAuthentication> 要素は、IIS 6.0 AuthType および AuthFlags メタベース プロパティの一部を置き換えます。

段取り

IIS 7 以降の既定のインストールには、ダイジェスト認証の役割サービスは含まれません。 IIS 7 以降でダイジェスト認証を使用するには、役割サービスをインストールし、Web サイトまたはアプリケーションの匿名認証を無効にしてから、サイトまたはアプリケーションのダイジェスト認証を有効にする必要があります。

ダイジェスト認証の役割サービスをインストールするには、次の手順を使用します。

Windows Server 2012 または Windows Server 2012 R2

  1. タスク バーで [サーバー マネージャー]をクリックします。
  2. [サーバー マネージャー] で、[管理] メニューをクリックし、[役割と機能の追加] をクリックします。
  3. 役割と機能の追加ウィザードで、[次へ] をクリックします。 [インストールの種類] を選択し、[次へ] をクリックします。 対象サーバーを選択し、[次へ] をクリックします。
  4. [サーバーの役割] ページで [Web サーバー (IIS)] を展開し、[Web サーバー][セキュリティ][ダイジェスト認証] の順に展開します。 次へ をクリックします。
    Image of Web Server and Security pane expanded with Digest Authentication selected.
  5. [機能の選択] ページで、[次へ] をクリックします。
  6. [インストール オプションの確認] ページで、[インストール] をクリックします。
  7. [結果] ページで、 [閉じる]をクリックします。

Windows 8 または Windows 8.1

  1. [スタート] 画面で、ポインターを左下隅まで移動し、[スタート] ボタンを右クリックし、[コントロール パネル] をクリックします。
  2. [コントロール パネル][プログラムと機能] をクリックし、[Windows の機能の有効化または無効化] をクリックします。
  3. [インターネット インフォメーション サービス] を展開し、[World Wide Web Services] を展開し、[セキュリティ] を展開して、[ダイジェスト認証] を選択します。
    Screenshot of World Wide Web Services and Security pane expanded with Digest Authentication highlighted.
  4. OK をクリックします。
  5. 閉じるをクリックします。

Windows Server 2008 または Windows Server 2008 R2

  1. タスク バーで [スタート] をクリックし、[管理ツール] をポイントして、[サーバー マネージャー] をクリックします。
  2. [Server Manager] (サーバー マネージャー) 階層ウィンドウで [ロール] を展開し、[Web Server (IIS)] (Web サーバー (IIS)) をクリックします。
  3. [Web Server (IIS)] (Web サーバー (IIS)) ウィンドウで、[Role Services] (役割サービス) セクションまでスクロールし、[Add Role Services] (役割サービスの追加) をクリックします。
  4. 役割サービスの追加ウィザード[役割サービスの選択] ページで、[ダイジェスト認証] を選択し、[次へ] をクリックします。 Image of Select Role Services page displaying Digest Authentication option selected.
  5. [インストール オプションの確認] ページで、[インストール] をクリックします。
  6. [結果] ページで、 [閉じる]をクリックします。

Windows Vista または Windows 7

  1. タスク バーで、[スタート][コントロール パネル] の順にクリックします。
  2. [コントロール パネル][プログラムと機能] をクリックし、[Turn Windows Features on or off] (Windows の機能の有効化または無効化) をクリックします。
  3. [インターネット インフォメーション サービス] を展開し、[World Wide Web Services][セキュリティ][ダイジェスト認証] の順に展開して[OK] をクリックします。
    Screenshot of World Wide Web Services and Security pane expanded showing Digest Authentication selected.

操作方法

ダイジェスト認証を有効にして、匿名認証を無効にする方法

  1. インターネット インフォメーション サービス (IIS) マネージャーを開きます。

    • Windows Server 2012 または Windows Server 2012 R2 を使用している場合:

      • タスク バーで、[サーバー マネージャー] をクリックし、[ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows 8 または Windows 8.1 を使用している場合:

      • Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
    • Windows Server 2008 または Windows Server 2008 R2 を使用している場合:

      • タスク バーで、[スタート] ボタンをクリックし、[管理ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows Vista または Windows 7 を使用している場合:

      • タスク バーで、[スタート][コントロール パネル] の順にクリックします。
      • [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ウィンドウで、サーバー名を展開し、[サイト] を展開し、基本認証を有効にするサイト、アプリケーション、または Web サービスをクリックします。

  3. [ホーム] ウィンドウの [セキュリティ] セクションまでスクロールし、[認証] をダブルクリックします。
    Image of Home pane in Security section with Authentication application highlighted.

  4. [認証] ウィンドウで [ダイジェスト認証] を選択し、[操作] ウィンドウで [有効] をクリックします。

  5. [認証] ウィンドウで [匿名認証] を選択し、[操作] ウィンドウで [無効] をクリックします。
    Image of Authentication pane displaying Anonymous Authentication option highlighted.

構成

<digestAuthentication> 要素は、サイト、アプリケーション、仮想ディレクトリ、URL レベルで構成できます。 役割サービスをインストールすると、IIS 7 は ApplicationHost.config ファイルに次の構成設定をコミットします。

<digestAuthentication enabled='false' />

属性

属性 説明
enabled 省略可能な Boolean 属性です。

ダイジェスト認証を有効にするかどうかを指定します。

既定値は false です。
realm 省略可能で、 String 型の属性。

ダイジェスト認証の領域を指定します。

子要素

なし。

構成サンプル

次の構成サンプルでは、Web サイト、Web アプリケーション、または Web サービスのダイジェスト認証を有効にします。 既定では、これらの設定は ApplicationHost.config ファイルに含める必要があります。また、これらの設定を <location> 要素に含め、path 属性を使用して、認証設定を適用する Web サイトまたはアプリケーションを定義する必要があります。

<security>
   <authentication>
      <anonymousAuthentication enabled="false" />
      <digestAuthentication enabled="true" />
   </authentication>
</security>

サンプル コード

次の例では、サイトのダイジェスト認証を有効にします。

AppCmd.exe

appcmd.exe set config "Contoso" -section:system.webServer/security/authentication/digestAuthentication /enabled:"True" /commit:apphost

Note

AppCmd.exe を使用してこれらの設定を構成する場合は、commit パラメーターを必ず apphost に設定する必要があります。 これにより、ApplicationHost.config ファイルの適切な場所セクションに構成設定がコミットされます。

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample {

   private static void Main() {

      using(ServerManager serverManager = new ServerManager()) { 
         Configuration config = serverManager.GetApplicationHostConfiguration();

         ConfigurationSection digestAuthenticationSection = config.GetSection("system.webServer/security/authentication/digestAuthentication", "Contoso");
         digestAuthenticationSection["enabled"] = true;

        serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample
   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration

      Dim digestAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/digestAuthentication", "Contoso")
      digestAuthenticationSection("enabled") = True

      serverManager.CommitChanges()
   End Sub
End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";

var digestAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/digestAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso");
digestAuthenticationSection.Properties.Item("enabled").Value = true;

adminManager.CommitChanges();

VBScript

Set adminManager = CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"

Set digestAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/digestAuthentication", "MACHINE/WEBROOT/APPHOST/Contoso")
digestAuthenticationSection.Properties.Item("enabled").Value = True

adminManager.CommitChanges()