Show Table of Contents
12.4. Squid の認証
認証については、
Squid のソースコードは SMB (Windows NT や Samba などの SMB サーバー)、DB (SQL データベース)、LDAP (Lightweight Directory Access Protocol) などの helpers と呼ばれる認証バックエンドと連携します。Squid が proxy_auth ACL を使用するように設定されている場合に、ユーザーは認証されます。
/etc/squid/squid.conf の auth_param ディレクティブで、どの認証ヘルパープログラムを使用するのかを Squid に指示を出します。プログラムと必要に応じてコマンドラインのオプションを指定します。
auth_param scheme parameter [setting]
例12.6 proxy_auth ACL の追加
個別のユーザー名を指定して、
proxy_auth ACL エントリーを Squid の設定に追加します。この例では、lisa、sarah、joe、frank という名前のユーザーが常にプロキシーを使用できるようにしています。その他のユーザーは、日中の時間のみ許可されます。
acl foo proxy_auth REQUIRED acl bar proxy_auth lisa sarah frank joe acl daytime time 08:00-17:00 http_access allow foo daytime http_access allow bar http_access deny all
12.4.1. LDAP での認証
この設定では、
Squid は LDAP を使用してユーザーを認証してから、ユーザーのインターネットアクセスを許可します。Squid のソースコードは、認証のために認証のバックエンド (LDAP) に接続します。ユーザー は、ユーザー名とパスワードを入力してからでないと、Web ページに進めません。Squid は、Squid LDAP 認証ヘルパー (squid_ldap_auth) を使用して、Squid が LDAP ディレクトリーに接続して、基本的な HTTP 認証のユーザー名とパスワードを検証できるようにします。
以下のように
/etc/squid/squid.conf を編集して Squid を ldap.example.com に接続します。
auth_param basic program /usr/lib64/squid/basic_ldap_auth -b "dc=example,dc=com" -f "uid=%s" -c 2 -t 2 -h ldap.example.com otherldap.example.com
SSL/TLS のセキュアなチャネルを使用して、LDAP サーバー上で
Squid ユーザーを認証する場合は、squid_ldap_auth プログラムに -ZZ の引数を渡します。
auth_param basic program /usr/lib64/squid/basic_ldap_auth -v 3 -ZZ -b "dc=yourcompany,dc=com" -D uid=some-user,ou=People,dc=yourcompany,dc=com -w password -f uid=%s ldap.yourcompany.com
TLS とSSL など、複数の OpenLDAP サーバーに対して認証を行う場合には
/etc/squid/squid.conf ファイルで auth_param を指定する必要があります。
- TLS 用に
/etc/squid/squid.confを編集します。auth_param basic program /usr/lib64/squid/basic_ldap_auth -Z -b "dc=example,dc=com" -f "uid=%s" -c 2 -t 2 -h ldap.example.com
SSL の場合は以下のように変更します。auth_param basic program /usr/lib64/squid/basic_ldap_auth -b "dc=example,dc=com" -f "uid=%s" -c 2 -t 2 -H ldaps://ldap.example.com
テストの実施場所-b - Specifies the base DN under which the users are located. -f - Specifies LDAP search filter to locate the user DN. -c - Specifies timeout used when connecting to LDAP servers. -t - Specifies time limit on LDAP search operations. -h - Specifies the LDAP server to connect to. -H - Specities the LDAP server to connect to by LDAP URI
Squidサービスを再起動します。~]#
systemctl restart squid
12.4.2. Kerberos での認証
以下の手順に従い、Red Hat Enterprise Linux 7 の
Squid プロキシーが Kerberos 認証を使用するように設定します。また、前提条件として、まずRed Hat Enterprise Linux 用の Samba、Common Internet File System (CIFS) ファイルサーバーをインストールします。Smba のインストールに関する詳しい情報は、『Red Hat Enterprise Linux 7 システム管理者ガイド』の「Samba」のセクションを参照してください。
手順12.4 Red Hat Enterprise Linux 7 上の Squid が Kerberos 認証を使用するように設定する
Squidが Active Directory (AD) ドメインに参加するように設定します。/etc/krb5.confファイルを編集します。[libdefaults] default_realm = EXAMPLE.COM dns_lookup_kdc = no dns_lookup_realm = no default_keytab_name = /etc/krb5.keytab ; for Windows 2003 default_tgs_enctypes = rc4-hmac des-cbc-crc des-cbc-md5 default_tkt_enctypes = rc4-hmac des-cbc-crc des-cbc-md5 permitted_enctypes = rc4-hmac des-cbc-crc des-cbc-md5 ; for Windows 2008 with AES ; default_tgs_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5 ; default_tkt_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5 ; permitted_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5 [realms] EXAMPLE.COM = { kdc = 192.168.0.1 admin_server = 192.168.0.1 } [domain_realm] example.com = EXAMPLE.COM .example.com = EXAMPLE.COM [logging] kdc = FILE:/var/log/kdc.log admin_server = FILE:/var/log/kadmin.log default = FILE:/var/log/krb5lib.logkinitコマンドで検証します。~]#
kinit testuser1~]#
kinit administrator- 以下のように
/etc/samba/smb.confファイルを編集します。[global] workgroup = EXAMPLE password server = 192.168.0.1 # Remember to put the realm all in CAPS: realm = EXAMPLE.COM security = ads idmap uid = 16777216-33554431 idmap gid = 16777216-33554431 template shell = /bin/bash winbind use default domain = true winbind offline logon = false winbind enum users = yes winbind enum groups = yes encrypt passwords = yes log file = /var/log/samba/log.%m max log size = 50 passdb backend = tdbsam load printers = yes cups options = raw kerberos method = system keytab
- AD ドメインに参加します。
~]#
net ads join -U Administrator
net ads keytabコマンドで、HTTP/fqdn の keytab を作成します。~]#
kinit administrator~]#export KRB5_KTNAME=FILE:/etc/squid/HTTP.keytab~]#net ads keytab CREATE~]#net ads keytab ADD HTTPkeytab ファイルを検証します。~]#
klist -k /etc/squid/HTTP.keytab注記
ホスト名が/etc/hostsファイルで正しく設定されていることを確認します。- このファイルが
Squidに含まれていることを確認してください。~]#
rpm -q squidsquid-3.1.10-1.el6.x86_64~]#
rpm -ql squid | grep kerb/usr/lib64/squid/negotiate_kerberos_auth /usr/lib64/squid/negotiate_kerberos_auth_test /usr/lib64/squid/squid_kerb_auth /usr/lib64/squid/squid_kerb_auth_test - 以下のように
/etc/squid/squid.confを変更してください。auth_param negotiate program /usr/lib64/squid/squid_kerb_auth -d -s HTTP/squid.example.com@EXAMPLE.COM auth_param negotiate children 10 auth_param negotiate keep_alive on acl kerb_auth proxy_auth REQUIRED (content truncated) http_access allow kerb_auth http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localnet http_access allow localhost http_access deny all (content truncated)
Squidプロセスオーナーで読み込み可能な .keytab ファイルを設定します。~]#
chgrp squid /etc/squid/HTTP.keytab~]#
chmod g+r /etc/squid/HTTP.keytab- 以下の行を
/etc/sysconfig/squidファイルに追加します。KRB5_KTNAME="/etc/squid/HTTP.keytab " export KRB5_KTNAME
Squidサービスを起動します。~]#
service squid start- Kerberos クライアントを設定して、Web ブラウザーが
Squidプロキシーを使用するように設定します。Key Distribution Center (KDC) から Kerberos チケットを取得します。~]#
kinit testuser1任意の Web サイトにアクセスしてみてください。Web ブラウザーで、ユーザー名またはパスワードが求められないはずです。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.