aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/http/headers/proxy-authorization/index.html
blob: f7dafee9a1bab4f8a9e60d2a0663060aaefe3f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
title: Proxy-Authorization
slug: Web/HTTP/Headers/Proxy-Authorization
tags:
  - 请求首部
  - 身份验证
  - 首部
translation_of: Web/HTTP/Headers/Proxy-Authorization
---
<div>{{HTTPSidebar}}</div>

<p><strong><code>Proxy-Authorization</code></strong> 是一个请求首部,其中包含了用户代理提供给代理服务器的用于身份验证的凭证。这个首部通常是在服务器返回了 {{HTTPStatus("407")}} <code>Proxy Authentication Required</code> 响应状态码及 {{HTTPHeader("Proxy-Authenticate")}} 首部后发送的。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Request header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>no</td>
  </tr>
 </tbody>
</table>

<h2 id="语法">语法</h2>

<pre class="syntaxbox">Proxy-Authorization: &lt;type&gt; &lt;credentials&gt;</pre>

<h2 id="指令">指令</h2>

<dl>
 <dt>&lt;type&gt;</dt>
 <dd><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#Authentication_schemes">身份验证类型</a>。一个常见的类型是 <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#Basic_authentication_scheme">"基本验证"。</a>IANA 机构维护了 <a href="http://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml">一系列的身份验证机制</a></dd>
 <dt>&lt;credentials&gt;</dt>
 <dd>凭证的构成方式如下:
 <ul>
  <li>将用户名和密码用冒号拼接(aladdin:opensesame)。</li>
  <li>将拼接生成的字符串使用 <a href="/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding">base64</a> 编码方式进行编码(YWxhZGRpbjpvcGVuc2VzYW1l)。</li>
 </ul>

 <div class="note">
 <p><strong>注意:</strong> Base64 编码方式不是用来加密或者获取摘要的!这种方法的安全性相当于将凭证使用明文发送(base64 是一种可逆编码方式)。在使用基本身份验证方式的时候推荐与 HTTPS 搭配使用。</p>
 </div>
 </dd>
</dl>

<h2 id="示例">示例</h2>

<pre>Proxy-Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Title</th>
  </tr>
  <tr>
   <td>{{RFC("7235", "Proxy-Authorization", "4.4")}}</td>
   <td>HTTP/1.1: Authentication</td>
  </tr>
  <tr>
   <td>{{RFC("7617")}}</td>
   <td>The 'Basic' HTTP Authentication Scheme</td>
  </tr>
 </tbody>
</table>

<h2 id="相关内容">相关内容</h2>

<ul>
 <li><a href="/en-US/docs/Web/HTTP/Authentication">HTTP authentication</a></li>
 <li>{{HTTPHeader("Proxy-Authenticate")}}</li>
 <li>{{HTTPHeader("WWW-Authenticate")}}</li>
 <li>{{HTTPHeader("Authorization")}}</li>
 <li>{{HTTPStatus("401")}}, {{HTTPStatus("403")}}, {{HTTPStatus("407")}}</li>
</ul>