Skip to content

Commit 29f8203

Browse files
committed
Remove documentation/example of HTTP Digest Authorization
It was declared obsolete as a standard in 2011. Some of the supporting code is still technically part of the SAPI layer, but there's no reason to document it here. php/doc-en@61d5b83
1 parent d1c626e commit 29f8203

File tree

1 file changed

+2
-70
lines changed

1 file changed

+2
-70
lines changed

features/http-auth.xml

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 2d1981cc3003cd94f5fb88e0473eed2c5b26efde Maintainer: hirokawa Status: ready -->
3+
<!-- EN-Revision: 61d5b83d9145d58515ad4c93c6125a339fb5eeda Maintainer: hirokawa Status: ready -->
44
<!-- CREDITS: shimooka,takagi,mumumu -->
55
<chapter xml:id="features.http-auth" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
66
<title>PHP による HTTP 認証</title>
@@ -18,8 +18,7 @@
1818
パスワード、認証型が代入された状態で呼ばれます。
1919
定義済みの変数は、配列
2020
<varname>$_SERVER</varname> でアクセス可能です。
21-
"Basic" 認証 と "Digest" 認証
22-
<emphasis>のみ</emphasis> がサポートされています。詳細は、
21+
"Basic" 認証 <emphasis>のみ</emphasis> がサポートされています。詳細は、
2322
<function>header</function>を参照ください。
2423
</simpara>
2524

@@ -45,73 +44,6 @@ if (!isset($_SERVER['PHP_AUTH_USER'])) {
4544
</example>
4645
</para>
4746

48-
<para>
49-
<example>
50-
<title>Digest HTTP 認証の例</title>
51-
<para>
52-
この例は、シンプルな Digest HTTP 認証スクリプトをどの様に実装するか
53-
を示しています。
54-
その他情報については、<link xlink:href="&url.rfc;2617">RFC 2617</link>
55-
を読んでください。
56-
</para>
57-
<programlisting role="php">
58-
<![CDATA[
59-
<?php
60-
$realm = 'Restricted area';
61-
62-
//user => password
63-
$users = array('admin' => 'mypass', 'guest' => 'guest');
64-
65-
66-
if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
67-
header('HTTP/1.1 401 Unauthorized');
68-
header('WWW-Authenticate: Digest realm="'.$realm.
69-
'",qop="auth",nonce="'.uniqid().'",opaque="'.md5($realm).'"');
70-
71-
die('ユーザーがキャンセルボタンを押した時に送信されるテキスト');
72-
}
73-
74-
75-
// PHP_AUTH_DIGEST 変数を精査する
76-
if (!($data = http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) ||
77-
!isset($users[$data['username']]))
78-
die('誤った証明書です!');
79-
80-
81-
// 有効なレスポンスを生成する
82-
$A1 = md5($data['username'] . ':' . $realm . ':' . $users[$data['username']]);
83-
$A2 = md5($_SERVER['REQUEST_METHOD'].':'.$data['uri']);
84-
$valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2);
85-
86-
if ($data['response'] != $valid_response)
87-
die('誤った証明書です!');
88-
89-
// OK, 有効なユーザー名とパスワードだ
90-
echo 'あなたは次のユーザーとしてログインしています: ' . $data['username'];
91-
92-
// http auth ヘッダをパースする関数
93-
function http_digest_parse($txt)
94-
{
95-
// データが失われている場合への対応
96-
$needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1);
97-
$data = array();
98-
$keys = implode('|', array_keys($needed_parts));
99-
100-
preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER);
101-
102-
foreach ($matches as $m) {
103-
$data[$m[1]] = $m[3] ? $m[3] : $m[4];
104-
unset($needed_parts[$m[1]]);
105-
}
106-
107-
return $needed_parts ? false : $data;
108-
}
109-
?>
110-
]]>
111-
</programlisting>
112-
</example>
113-
</para>
114-
11547
<note>
11648
<title>互換性に関する注意</title>
11749
<para>

0 commit comments

Comments
 (0)