<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="10" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[10]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">CGI</anchor> の<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">メタ変数</anchor> <dfn><code class="CGI" xml:lang="en">AUTH_TYPE</code></dfn> は、
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">鯖</anchor>が<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">利用者</anchor>を<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">認証</anchor>するのに使った仕組みを識別します。 <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="9" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;9</anchor-internal></src></p><section><h1>仕様書</h1><refs xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:"><ul xmlns="http://www.w3.org/1999/xhtml"><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="9" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[9]</anchor-end> <cite xml:lang="en">RFC 3875 - The Common Gateway Interface (CGI) Version 1.1</cite> (<time>2011-11-20 06:09:05 +09:00</time> 版) <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://tools.ietf.org/html/rfc3875#section-4.1.1">http://tools.ietf.org/html/rfc3875#section-4.1.1</anchor-external></li></ul></refs></section><section><h1>値</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="11" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[11]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">メタ変数</anchor> <code class="CGI" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">AUTH_TYPE</anchor></code> の値は、<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">鯖</anchor>が<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">利用者</anchor>の<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">認証</anchor>に使った仕組みを示します
<src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="9" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;9</anchor-internal></src>。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="12" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[12]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">クライアント</anchor>との<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">プロトコル</anchor>や<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">鯖</anchor>の実装によって定義される、
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">大文字・小文字不区別</anchor>の値を持ちます。 <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="9" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;9</anchor-internal></src></p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="13" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[13]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTTP</anchor> では、<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">クライアント</anchor>からの<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">要求</anchor>が<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">認証</anchor>を必要としている場合には、
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">鯖</anchor>は、<code class="HTTP" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Authorization</anchor></code> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">頭欄</anchor>の <code class="ABNF" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">auth-scheme</anchor></code>
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">字句</anchor>からの値を設定しなければ<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:"><strong xmlns="http://www.w3.org/1999/xhtml">なりません</strong></anchor>。 <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="9" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;9</anchor-internal></src></p><section><h1>構文</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="14" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[14]</anchor-end> 構文は次のように定義されています <src xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:10:"><anchor-internal xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="9" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">&gt;&gt;9</anchor-internal></src>。<pre class="ABNF code">      AUTH_TYPE      = &quot;&quot; | <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">auth-scheme</anchor>
      <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">auth-scheme</anchor>    = &quot;<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Basic</anchor>&quot; | &quot;<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Digest</anchor>&quot; | extension-auth
      extension-auth = <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">token</anchor></pre></p></section></section><section><h1>文脈</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="17" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[17]</anchor-end> 
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTTPサーバー</anchor>が<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTTP認証</anchor>の処理を担当し、
<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">HTTP認証</anchor>を通過した<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">要求</anchor>を <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">CGIスクリプト</anchor>に引き渡すという形の<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">アプリケーションサーバー</anchor>の実装形態を想定しています。</p></section><section><h1>歴史</h1><section><h1>HTTP CGI</h1><figure class="quote"><figcaption><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="2" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[2]</anchor-end> [NCSA]</figcaption><blockquote><p>If the server supports user authentication, and the script is protects, this is the protocol-specific authentication method used to validate the user. </p></blockquote><p>サーバーが利用者認証に対応していれば、
そしてスクリプトが保護されていれば、
この変数の値は利用者の認証に使用したプロトコル規定の認証方式です。</p></figure><figure class="quote"><figcaption><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="16" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[16]</anchor-end> 6.1.1. AUTH_TYPE (CGI/1.1 draft 03)</figcaption><blockquote><p>This variable is specific to requests made via the &quot;http&quot;</p><p>scheme.</p></blockquote><p>この変数は「http」方式を介してなされた要求について設定します。</p><blockquote><p>If the Script-URI required access authentication for external</p><p>access, then the server MUST set the value of this variable</p><p>from the 'auth-scheme' token in the request's &quot;Authorization&quot;</p><p>header field. Otherwise it is set to NULL.</p></blockquote><p><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Script-URI</anchor>が外部からの接続に接続認証が必要な場合、
サーバーはこの変数の値を要求の「Authorization」(認証)頭領域の
「auth-scheme」字句から設定し<em>なければなりません</em>。
それ以外の場合は NULL を設定します。</p><pre>  AUTH_TYPE   = &quot;&quot; | auth-scheme
  auth-scheme = &quot;Basic&quot; | &quot;Digest&quot; | token</pre><blockquote><p>HTTP access authentication schemes are described in section 11</p><p>of the HTTP/1.1 specification [8]. The auth-scheme is not</p><p>case-sensitive.</p></blockquote><p>HTTP 接続認証方式は HTTP/1.1 仕様書の第11章で説明されています。
auth-scheme は大文字・小文字を区別しません。</p><blockquote><p>Servers MUST provide this metavariable to scripts if the</p><p>request header included an &quot;Authorization&quot; field that was</p><p>authenticated.</p></blockquote><p>サーバーは、要求頭に「Authorization」領域が含まれていて、
それを認証した場合、
このメタ変数をスクリプトに提供し<em>なければなりません</em>。</p></figure><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="1" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[1]</anchor-end> 大文字・小文字を区別<em>する</em>が正しいね。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="3" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[3]</anchor-end> [NCSA] の当時は HTTP 認証がまだ標準化されていなかったので、かなりあいまいな表現になっていますのです。</p><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="4" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[4]</anchor-end> [NCSA] ではスクリプトが保護されていることを要求していました。 (この要求は <code class="CGI"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">REMOTE_USER</anchor></code> にもありました。認証についての情報は安全じゃないといけないってことですな。 [COAR] では省かれてますが。</p></section><section><h1>SIP CGI</h1><figure class="quote"><figcaption><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="5" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[5]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">RFC 3050</anchor> 5.5.1.1</figcaption><blockquote><p>If the target of the message required access authentication for
external access, then the server MUST set the value of this variable
from the auth-scheme token in the message's Authorization header
field.  Otherwise it is not defined.</p></blockquote><p>メッセージの対象が外部接続に対する接続認証を必須としているなら、
サーバーはこの変数の値をメッセージの
<code class="SIP">Authorization</code> 頭欄の
<code class="SIP">auth-scheme</code>
字句から設定しなければ<strong>なりません (MUST)</strong>。
そうでなければこれは定義されません。</p><blockquote><ul><li>AUTH_TYPE    =  &quot;&quot; | auth-scheme</li><li>auth-scheme  =  &quot;Basic&quot; | &quot;Digest&quot; | &quot;PGP&quot; | token</li></ul></blockquote><blockquote><p>SIP access authentication schemes are described in sections 14 and 15
of the SIP/2.0 specification [2].  The auth-scheme is not case-
sensitive.</p></blockquote><p>SIP 接続認証方式は <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">SIP/2.0</anchor>
仕様書の14章と15章で説明されています。
<code class="SIP">auth-scheme</code>
は大文字・小文字を区別しません。</p><blockquote><p>Servers MUST provide this metavariable to scripts if the message
header included an Authorization field that was authenticated.</p></blockquote><p>サーバーはこのメタ変数をメッセージ頭が認証された
<code class="CGI">Authorization</code>
欄を含んでいる場合に提供しなければ<strong>なりません (MUST)</strong>。</p><blockquote><p>For the complex authentication schemes, the server SHOULD perform the
authentication checking itself.  If the authentication failed, this
metavariable SHOULD NOT be set.</p></blockquote><p>複雑な認証方式の場合は、
サーバーは認証検査を自信で行う<strong>べきです (SHOULD)</strong>。
認証が失敗した場合には、
このメタ変数は設定する<strong>べきではありません (<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">SHOULDNOT</anchor>)</strong>。</p><blockquote><p>If several authentication credentials, with multiple schemes, are
present in the message, this variable SHOULD be set to correspond to
the authenticated credentials with the strongest scheme the server
supports.  If credentials are present for several domains, the server
SHOULD NOT perform any action on credentials from domains external to it.</p></blockquote><p>メッセージ中に複数の方式での認証が用意されていたなら、
この変数はそのサーバーが対応している最強の認証に対応して設定する<strong>べきです (SHOULD)</strong>。
認証が複数の範囲に対して用意されていたなら、
そのサーバーから外側の範囲の認証には何の動作も行う<strong>べきではありません (SHOULD NOT)</strong>。</p><blockquote><p>If both Authorization and Proxy-Authorization headers are present,
the server SHOULD perform the authorizations based on the appropriate
header for the context in which it is running.  For example, a server
which is a proxy server and a registrar would use Authorization
headers for REGISTER messages aimed at its local domains, and Proxy-Authorization headers for all other messages.</p></blockquote><p><code class="SIP">Authorization</code>,
<code class="SIP">Proxy-Authorization</code>
両欄が用意されていた場合、
サーバーはその動作している場面に適切な頭を用いて認証する<strong>べきです (SHOULD)</strong>。
例えば、串サーバー及び registrar
は局部ドメインの <code class="SIP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">REGISTER</anchor></code>
メッセージに <code class="SIP">Authorization</code>
頭を使い、他の全てのメッセージには
<code class="SIP">Proxy-Authorization</code>
頭を使います。</p></figure></section></section><section><h1>テスト・ケース</h1><refs xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:"><ul xmlns="http://www.w3.org/1999/xhtml"><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="8" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[8]</anchor-end> <anchor-external xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resScheme="URI" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:resParameter="http://suika.fam.cx/~wakaba/test/web/cgi/var-auth/auth.cgi">http://suika.fam.cx/~wakaba/test/web/cgi/var-auth/auth.cgi</anchor-external></li></ul></refs></section><section><h1>関連</h1><p><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="15" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[15]</anchor-end> <code class="CGI" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">AUTH_TYPE</anchor></code> が設定されている場合、その認証方式で<anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">利用者</anchor>名が提供されていれば、
<code class="CGI" xml:lang="en"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">REMOTE_USER</anchor></code> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">メタ変数</anchor>によりアクセスできます。</p></section><section><h1>メモ</h1><ul><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="6" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[6]</anchor-end> 結局このメタ変数の値になり得る値については、 <code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Authorization:</anchor></code> 欄の説明を参照。</li><li><anchor-end xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:" a0:anchor="7" xmlns:a0="urn:x-suika-fam-cx:markup:suikawiki:0:9:">[7]</anchor-end> <anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">Apache</anchor> の実装では、サーバー側で認証が設定されていない (のに CGI スクリプトが勝手に <code class="HTTP"><anchor xmlns="urn:x-suika-fam-cx:markup:suikawiki:0:9:">WWW-Authenticate</anchor></code> を送った) 時にも (サーバーとしては認証の設定がされてないから、認証は素通しして) <code class="CGI">AUTH_TYPE</code> は設定しないんですけど、 <code class="CGI">HTTP_AUTHORIZATION</code> はこの場合でも設定してくれないので、結局どうしても認証することができないんですよね。ちょっと不便かもー。</li></ul></section></body></html>