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

20.15. OAuth認可/認証 #

<title>OAuth Authorization/Authentication</title>

OAuth 2.0 is an industry-standard framework, defined in <ulink url="https://datatracker.ietf.org/doc/html/rfc6749">RFC 6749</ulink>, to enable third-party applications to obtain limited access to a protected resource. OAuth client support has to be enabled when <productname>PostgreSQL</productname> is built, see <xref linkend="installation"/> for more information. OAuth 2.0は、RFC 6749で定義されている業界標準のフレームワークであり、サードパーティのアプリケーションが保護されたリソースへの限定されたアクセスを取得できるようにします。 PostgreSQLを構築する際、OAuthクライアントサポートを有効にする必要があります。詳細については第17章を参照してください。

This documentation uses the following terminology when discussing the OAuth ecosystem: この文書では、OAuthエコシステムについて議論する際に次の用語を使用しています。

リソース所有者(またはエンドユーザ)

The user or system who owns protected resources and can grant access to them. This documentation also uses the term <emphasis>end user</emphasis> when the resource owner is a person. When you use <application>psql</application> to connect to the database using OAuth, you are the resource owner/end user. 保護されたリソースを所有し、アクセスを与えることができるユーザまたはシステム。 この文書は、リソース所有者が個人の場合にもエンドユーザという用語を使用します。 psqlを使用して、OAuthを使用してデータベースに接続する場合、ユーザはリソース所有者/エンドユーザになります。

クライアント

The system which accesses the protected resources using access tokens. Applications using libpq, such as <application>psql</application>, are the OAuth clients when connecting to a <productname>PostgreSQL</productname> cluster. アクセストークンを使用して保護されたリソースにアクセスするシステム。 psqlなどのlibpqを使用するアプリケーションは、PostgreSQLクラスタに接続するときのOAuthクライアントです。

リソースサーバ

The system hosting the protected resources which are accessed by the client. The <productname>PostgreSQL</productname> cluster being connected to is the resource server. クライアントによってアクセスされる保護されたリソースをホスティングするシステム。 接続されるPostgreSQLクラスタはリソースサーバです。

プロバイダ

The organization, product vendor, or other entity which develops and/or administers the OAuth authorization servers and clients for a given application. Different providers typically choose different implementation details for their OAuth systems; a client of one provider is not generally guaranteed to have access to the servers of another. 特定のアプリケーションのためにOAuth認証サーバおよびクライアントを開発および/または管理する組織、プロダクトベンダ、その他のエンティティ。 典型的には、プロバイダが異なれば、OAuthシステムに対して選択する実装の詳細も異なります。 あるプロバイダのクライアントが別のプロバイダのサーバに対してアクセスできる保証は通常ありません。

This use of the term "provider" is not standard, but it seems to be in wide use colloquially. (It should not be confused with OpenID's similar term "Identity Provider". While the implementation of OAuth in <productname>PostgreSQL</productname> is intended to be interoperable and compatible with OpenID Connect/OIDC, it is not itself an OIDC client and does not require its use.) この「プロバイダ」という用語の使用は標準的ではありませんが、一般的に広く使用されているようです。 (OpenIDの類似用語である「IDプロバイダ」と混同しないでください。 PostgreSQLでのOAuthの実装はOpenID Connect/OIDCとの相互運用と互換性を意図していますが、自分自身はOIDCクライアントではないため、使用する必要はありません。)

認可サーバ

The system which receives requests from, and issues access tokens to, the client after the authenticated resource owner has given approval. <productname>PostgreSQL</productname> does not provide an authorization server; it is the responsibility of the OAuth provider. 認証されたリソース所有者が承認した後に、クライアントからアクセストークンのリクエストを受信し、アクセストークンをクライアントに発行するシステム。 PostgreSQLは認可サーバを提供しません。これはOAuthプロバイダの責任です。

発行者

An identifier for an authorization server, printed as an <literal>https://</literal> URL, which provides a trusted "namespace" for OAuth clients and applications. The issuer identifier allows a single authorization server to talk to the clients of mutually untrusting entities, as long as they maintain separate issuers. OAuthクライアントのための信頼された「名前空間」で、https:// URLの形で印字される認可サーバの識別子。 発行者識別子により、それらが別々の発行者を保持する限り、単一の認可サーバが相互に信用していないエンティティのクライアントと話すことを可能にします。

注記

For small deployments, there may not be a meaningful distinction between the "provider", "authorization server", and "issuer". However, for more complicated setups, there may be a one-to-many (or many-to-many) relationship: a provider may rent out multiple issuer identifiers to separate tenants, then provide multiple authorization servers, possibly with different supported feature sets, to interact with their clients. 小規模な導入では、「プロバイダ」、「認可サーバ」、および「発行者」の間に意味のある区別がない場合があります。 ただし、より複雑な設定では、1対多(または多対多)のリレーションが存在する場合があります。 プロバイダは、複数の発行者識別子を別々のテナントに貸し出し、テナントがクライアントと対話するために、場合によっては異なる機能の組み合わせをサポートする複数の認証サーバを提供することがあります。

<productname>PostgreSQL</productname> supports bearer tokens, defined in <ulink url="https://datatracker.ietf.org/doc/html/rfc6750">RFC 6750</ulink>, which are a type of access token used with OAuth 2.0 where the token is an opaque string. The format of the access token is implementation specific and is chosen by each authorization server. PostgreSQLは、RFC 6750で定義されているベアラ(bearer)トークンをサポートします。 これは、OAuth 2.0で使用されるアクセストークンの型です。 トークンは不透明文字列です。 アクセストークンのフォーマットは実装固有であり、各認可サーバによって選択されます。

The following configuration options are supported for OAuth: OAuth用に、次の設定オプションがサポートされています。

issuer

An HTTPS URL which is either the exact <link linkend="auth-oauth-issuer">issuer identifier</link> of the authorization server, as defined by its discovery document, or a well-known URI that points directly to that discovery document. This parameter is required. ディスカバリー文書によって定義された認可サーバの正確な発行者識別子であるか、またはそのディスカバリー文書を直接指す既知のURIであるHTTPS URLです。 このパラメータは必須です。

When an OAuth client connects to the server, a URL for the discovery document will be constructed using the issuer identifier. By default, this URL uses the conventions of OpenID Connect Discovery: the path <literal>/.well-known/openid-configuration</literal> will be appended to the end of the issuer identifier. Alternatively, if the <literal>issuer</literal> contains a <literal>/.well-known/</literal> path segment, that URL will be provided to the client as-is. OAuthクライアントがサーバに接続する際に、その発行者識別子を用いてディスカバリー文書のURLを構築します。 デフォルトでは、このURLはOpenID Connect Discoveryの規約であるパス/.well-known/OpenID-configuration発行者識別子の末尾に付加されます。 あるいは、issuer/.well-known/パスセグメントを含んでいる場合、そのURLがそのままクライアントに提供されます。

警告

The OAuth client in libpq requires the server's issuer setting to exactly match the issuer identifier which is provided in the discovery document, which must in turn match the client's <xref linkend="libpq-connect-oauth-issuer"/> setting. No variations in case or formatting are permitted. libpqのOAuthクライアントは、サーバ発行者の設定が、正確にディスカバリー文書中で提供された発行者識別子と一致する必要があり、そしてそれはクライアントのoauth_issuer設定と一致しなければなりません。 大文字小文字やフォーマットの変更は許可されません。

scope

A space-separated list of the OAuth scopes needed for the server to both authorize the client and authenticate the user. Appropriate values are determined by the authorization server and the OAuth validation module used (see <xref linkend="oauth-validators" /> for more information on validators). This parameter is required. サーバがクライアントを認可し、ユーザを認証するのに必要な空白で区切られたOAuthスコープです。 認証サーバとOAuth検証モジュールによって適切な値が決まります(検証器の詳細は第50章を参照)。 このパラメータは必須です。

validator

The library to use for validating bearer tokens. If given, the name must exactly match one of the libraries listed in <xref linkend="guc-oauth-validator-libraries" />. This parameter is optional unless <literal>oauth_validator_libraries</literal> contains more than one library, in which case it is required. ベアラトークンの検証に使用するライブラリ。 指定する場合、名前はoauth_validator_librariesに列挙されているライブラリの1つと正確にマッチする必要があります。 このパラメータは、oauth_validator_librariesが複数のライブラリを含んでいる場合を除き、オプションです。複数のライブラリが含まれていれば必須です。

map

Allows for mapping between OAuth identity provider and database user names. See <xref linkend="auth-username-maps"/> for details. If a map is not specified, the user name associated with the token (as determined by the OAuth validator) must exactly match the role name being requested. This parameter is optional. OAuthアイデンティティプロバイダとデータベースユーザ名の間のマッピングを可能にします。 詳細は、20.2を参照してください。 マップが指定されていない場合、(OAuth検証器によって決定される)トークンに関連付けられたユーザ名は、要求されているロール名と正確にマッチする必要があります。 このパラメータはオプションです。

delegate_ident_mapping

An advanced option which is not intended for common use. 一般的な使用を目的としない高度なオプション。

When set to <literal>1</literal>, standard user mapping with <filename>pg_ident.conf</filename> is skipped, and the OAuth validator takes full responsibility for mapping end user identities to database roles. If the validator authorizes the token, the server trusts that the user is allowed to connect under the requested role, and the connection is allowed to proceed regardless of the authentication status of the user. 1に設定すると、pg_ident.confによる標準ユーザマッピングはスキップされ、OAuth検証器はデータベースロールに対するマッピングエンドユーザIDに対して完全な責任を負います。 検証器がトークンを認可すると、サーバはユーザが要求されたロールの下で接続できることを信頼し、ユーザの認証ステータスに関係なくコネクションを続行できます。

This parameter is incompatible with <literal>map</literal>. このパラメータはmapと互換性がありません。

警告

<literal>delegate_ident_mapping</literal> provides additional flexibility in the design of the authentication system, but it also requires careful implementation of the OAuth validator, which must determine whether the provided token carries sufficient end-user privileges in addition to the <link linkend="oauth-validators">standard checks</link> required of all validators. Use with caution. delegate_ident_mappingは認証システムのデザインに追加の柔軟性を提供しますが、提供されたトークンがすべての検証器に必要な標準チェックに加えて、十分なエンドユーザ権限を持っているかどうかを判断するOAuth検証器の注意深い実装も必要です。 注意して使用してください。