1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ダイジェスト認証をやってみよう

Posted at

勉強前イメージ

すぐできそうではある。

調査

そもそもダイジェスト認証 とは

ダイジェスト認証は、一言で言えばbasic認証のパワーアップ版になります。
詳細は こちら をごらんください

ダイジェスト認証してみる!

  • ダイジェスト認証設定前のwebページ

ただの文字列が表示されるだけのwebページ

1Mozilla Firefox 2022-02-03 18.19.08.png

  • ダイジェスト認証のファイルを作成

htdigest -c [ファイルパス] '[認証名]' [ユーザー名] のコマンドを使用します。
実行例が以下です。

htdigest -c /etc/httpd/conf.d/.digestpass 'Digest Auth Test' admin
[root@localhost conf.d]# htdigest -c /etc/httpd/conf.d/.digestpass 'Digest Auth Test' admin
Adding password for admin in realm Digest Auth Test.
New password: [adminのパスワードを入力]
Re-type new password: [adminのパスワードを再入力]
  • 認証ファイルの確認

生成された認証ファイルです。

cat /etc/httpd/conf.d/.digestpass
admin:Digest Auth Test:a9502XXXXXXXXXXXXXXXXXXX
  • 設定ファイルに追記
vi /etc/httpd/conf/httpd.conf

設定に以下に記載しているものを追記します。

  • AuthType : 認証方法。ちなみにbasic認証だと Basic が入る
  • AuthName : 認証名
  • AuthUserFile : パスワードファイルのパス
  • Require : valid-userにすると全ユーザになる。ユーザ名を指定することも可能
<Directory "/var/www/html">
    AuthType Digest
    AuthName "Digest Auth Test"
    AuthUserFile "/etc/httpd/conf.d/.digestpass"
    Require valid-user
</Directory>
  • httpdの再起動
service httpd restart
  • ダイジェスト認証設定後のwebページ

basic認証と一緒の表示がされます。

2Mozilla Firefox 2022-02-03 18.33.11.png

勉強後イメージ

大体わかってたけど、あまりbasic認証とほぼ変わらんねw

参考

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?