バージョンごとのドキュメント一覧

21.5. パスワード認証 #

<title>Password Authentication</title>

There are several password-based authentication methods. These methods operate similarly but differ in how the users' passwords are stored on the server and how the password provided by a client is sent across the connection. 複数のパスワードに基づく認証方式があります。 これらは似たような方法で使用されますが、ユーザのパスワードをサーバに格納する方法と、クライアントによって提供されたパスワードが接続を通じて送信される方法が異なります。

scram-sha-256

The method <literal>scram-sha-256</literal> performs SCRAM-SHA-256 authentication, as described in <ulink url="https://tools.ietf.org/html/rfc7677">RFC 7677</ulink>. It is a challenge-response scheme that prevents password sniffing on untrusted connections and supports storing passwords on the server in a cryptographically hashed form that is thought to be secure. scram-sha-256方式は、RFC 7677に記述された方法でSCRAM-SHA-256認証を実行します。 これはチャレンジ/レスポンス方式のひとつであり、信頼できない接続におけるパスワードの漏洩を防ぎ、安全だと見なされる暗号学的ハッシュ形式でパスワードをサーバに格納するのを支援します。

This is the most secure of the currently provided methods, but it is not supported by older client libraries. これは、現在実装されている認証方式の中では最も安全ですが、古いクライアントライブラリではサポートされていません。

md5

The method <literal>md5</literal> uses a custom less secure challenge-response mechanism. It prevents password sniffing and avoids storing passwords on the server in plain text but provides no protection if an attacker manages to steal the password hash from the server. Also, the MD5 hash algorithm is nowadays no longer considered secure against determined attacks. md5方式は、独自のより安全性の低いチャレンジ/レスポンス機構を使います。 パスワードの漏洩を防ぎ、平文でパスワードをサーバに格納するのを避けることができますが、攻撃者がサーバからパスワードハッシュを盗むことを防ぐことはできません。 また、MD5ハッシュアルゴリズムは、昨今では強い意志をもった攻撃に対して安全ではないと考えられています。

The <literal>md5</literal> method cannot be used with the <xref linkend="guc-db-user-namespace"/> feature. md5は、db_user_namespace機能と一緒に使用することはできません。

To ease transition from the <literal>md5</literal> method to the newer SCRAM method, if <literal>md5</literal> is specified as a method in <filename>pg_hba.conf</filename> but the user's password on the server is encrypted for SCRAM (see below), then SCRAM-based authentication will automatically be chosen instead. md5方式からより新しいSCRAM方式への移行を容易にするため、pg_hba.confmd5が指定されているにもかかわらず、パスワードがSCRAM(下記参照)で暗号化されている場合には、自動的にSCRAMに基づく認証が代わりに使用されます。

password

The method <literal>password</literal> sends the password in clear-text and is therefore vulnerable to password <quote>sniffing</quote> attacks. It should always be avoided if possible. If the connection is protected by SSL encryption then <literal>password</literal> can be used safely, though. (Though SSL certificate authentication might be a better choice if one is depending on using SSL). password方式は、パスワードを平文で送信するので、パスワード盗聴攻撃に対して脆弱です。 可能ならば、常に避けるようにしてください。 しかしながら、接続がSSL暗号で保護されていれば、passwordは安全に使用できます。 (もっとも、SSLの利用に依存するのであれば、SSL証明書認証がより良い選択かもしれません。)

<productname>PostgreSQL</productname> database passwords are separate from operating system user passwords. The password for each database user is stored in the <literal>pg_authid</literal> system catalog. Passwords can be managed with the SQL commands <xref linkend="sql-createrole"/> and <xref linkend="sql-alterrole"/>, e.g., <userinput>CREATE ROLE foo WITH LOGIN PASSWORD 'secret'</userinput>, or the <application>psql</application> command <literal>\password</literal>. If no password has been set up for a user, the stored password is null and password authentication will always fail for that user. PostgreSQLデータベースパスワードはオペレーティングシステムのユーザパスワードとも別のものです。 各データベースユーザのパスワードはpg_authidシステムカタログテーブルの中に格納されます。 CREATE ROLE foo WITH LOGIN PASSWORD 'secret'のように、パスワードはSQLコマンドCREATE ROLEALTER ROLEを使って管理できます。 あるいは、psql\passwordコマンドでも管理できます。 もしユーザに対してパスワードが設定されない場合、格納されるパスワードはNULLとなり、そのユーザのパスワード認証は常に失敗します。

The availability of the different password-based authentication methods depends on how a user's password on the server is encrypted (or hashed, more accurately). This is controlled by the configuration parameter <xref linkend="guc-password-encryption"/> at the time the password is set. If a password was encrypted using the <literal>scram-sha-256</literal> setting, then it can be used for the authentication methods <literal>scram-sha-256</literal> and <literal>password</literal> (but password transmission will be in plain text in the latter case). The authentication method specification <literal>md5</literal> will automatically switch to using the <literal>scram-sha-256</literal> method in this case, as explained above, so it will also work. If a password was encrypted using the <literal>md5</literal> setting, then it can be used only for the <literal>md5</literal> and <literal>password</literal> authentication method specifications (again, with the password transmitted in plain text in the latter case). (Previous PostgreSQL releases supported storing the password on the server in plain text. This is no longer possible.) To check the currently stored password hashes, see the system catalog <literal>pg_authid</literal>. パスワードにもとづく異なる認証方式が利用可能かどうかは、サーバ上でユーザのパスワードがどのように暗号化(正確には、ハッシュ化)されるのかに依存します。 これは、パスワードが設定されたときに、設定パラメータのpassword_encryptionによって制御されます。 パスワードがscram-sha-256によって暗号化されていれば、認証方式のscram-sha-256passwordで利用できます。 (ただし、後者の場合にはパスワードの転送が平文になります。) 前述のように、ここで認証方式のmd5を指定すると、scram-sha-256方式に自動的に切り替わります。 パスワードがmd5で暗号化されていると、md5passwordでのみ使用されます。 (ここでも、後者の場合にはパスワードが平文で転送されます。) (以前のPostgreSQLのリリースでは、パスワードを平文で格納することをサポートしていました。 これはもはや不可能です。) 現在格納されているパスワードのハッシュを確認するには、システムカタログpg_authidを参照してください。

To upgrade an existing installation from <literal>md5</literal> to <literal>scram-sha-256</literal>, after having ensured that all client libraries in use are new enough to support SCRAM, set <literal>password_encryption = 'scram-sha-256'</literal> in <filename>postgresql.conf</filename>, make all users set new passwords, and change the authentication method specifications in <filename>pg_hba.conf</filename> to <literal>scram-sha-256</literal>. 既存のインストールにおいて、md5からscram-sha-256にアップグレードするには、すべてのクライアントライブラリが十分新しく、SCRAMをサポートをできることを確認してから、postgresql.confpassword_encryption = 'scram-sha-256'を設定し、すべてのユーザに新しいパスワードを設定してもらい、pg_hba.confの認証方式をscram-sha-256に変更してください。