Basic認証
Basic認証(ベーシックにんしょう、Basic Authentication)とは、HTTPで定義される認証方式(HTTP認証)の一つ。基本認証と呼�…
| HTTP |
|---|
| 主要項目 |
| リクエストメソッド |
| ヘッダーフィールド |
| ステータスコード |
| 認証方式 |
| 脆弱性およびそれを利用した攻撃手法 |
Basic認証(ベーシックにんしょう、Basic Authentication)とは、HTTPで定義される認証方式(HTTP認証)の一つ。基本認証と呼ばれることも。
Basic認証では、ユーザ名とパスワードの組みをコロン ":" でつなぎ、Base64でエンコードして送信する。このため、盗聴や改竄が簡単であるという欠点を持つが、ほぼ全てのWebサーバおよびブラウザで対応しているため、広く使われている。
盗聴や改竄を防ぐため、後にDigest認証というユーザ名とパスワードをMD5でハッシュ化して送る方法が考えられた。
通信の流れ
典型的なBasic認証におけるHTTPクライアントとHTTPサーバの間の通信を紹介する。 だいたいの流れは以下のようになる。
- クライアントは認証が必要なページをリクエストする。しかし、通常ここではユーザ名とパスワードを送っていない。なぜならばクライアントはそのページが認証を必要とするか否かを知らないためである。
- サーバは401レスポンスコードを返し、認証領域 (authentication realm) や認証方式 (Basic認証) に関する情報をクライアントに知らせる。
- それを受けたクライアントは、認証領域(通常は、アクセスしているコンピュータやシステムの簡単な説明)をユーザに提示して、ユーザ名とパスワードの入力を求める。ユーザはここでキャンセルすることもできる。
- ユーザによりユーザ名とパスワードが入力されると、クライアントはリクエストに認証ヘッダを追加して再度送信する。
- 認証に成功すると、サーバは認証の必要なページのリクエストを処理する。一方、ユーザ名やパスワードが間違っていた時には、サーバは再び401レスポンスコードを返す。それによりクライアントは再びユーザにユーザ名とパスワードの入力を求める。
例
以下に、認証に成功した場合の例を示す。(番号は上記「通信の流れ」と対応させてある)
1.認証を伴わないリクエスト:
GET /private/index.html HTTP/1.1
Host: example.com
2.認証が必要であることを示すサーバのレスポンス:
HTTP/1.1 401 Authorization Required
Date: Wed, 11 May 2005 07:50:26 GMT
Server: Apache/1.3.33 (Unix)
WWW-Authenticate: Basic realm="SECRET AREA"
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
(ここに人間が読めるエラーメッセージが入る)
3.(クライアントによる提示、およびユーザによる入力):
<通信は行われない>
4.認証を伴うリクエスト (ユーザ名 "root"、パスワード "password"):
GET /private/index.html HTTP/1.1
Host: example.com
Authorization: Basic cm9vdDpwYXNzd29yZA{{=}}{{=}}
5.サーバのレスポンス
HTTP/1.1 200 OK
Date: Wed, 11 May 2005 07:50:26 GMT
(以下略)
関連項目
外部リンク
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.