OAuth validator modules implement their functionality by defining a set of callbacks. The server will call them as required to process the authentication request from the user. 《機械翻訳》OAuthバリデータモジュールは、一連のコールバックを定義することでその機能を実装する。 サーバは、ユーザからプロセス認証リクエストまで、必要に応じてそれらを呼び出しする。
The <function>startup_cb</function> callback is executed directly after
loading the module. This callback can be used to set up local state and
perform additional initialization if required. If the validator module
has state it can use <structfield>state->private_data</structfield> to
store it.
《機械翻訳》startup_cb
コールバックは、モジュールのロードの直後に実行されます。
このコールバックは、ローカルの状態を設定し、必要に応じて追加の初期設定を実行するために使用できます。
バリデータモジュールに状態がある場合は、state->private_data
それを格納するために使用できます。
typedef void (*ValidatorStartupCB) (ValidatorModuleState *state);
The <function>validate_cb</function> callback is executed during the OAuth
exchange when a user attempts to authenticate using OAuth. Any state set in
previous calls will be available in <structfield>state->private_data</structfield>.
《機械翻訳》validate_cb
コールバックは、ユーザがOAuthを使用して認証しようとするときに、OAuth交換中に実行される。
以前の呼び出しで設定された状態は、state->private_data
で使用できる。
typedef bool (*ValidatorValidateCB) (const ValidatorModuleState *state, const char *token, const char *role, ValidatorModuleResult *result);
<replaceable>token</replaceable> will contain the bearer token to validate.
<application>PostgreSQL</application> has ensured that the token is well-formed syntactically, but no
other validation has been performed. <replaceable>role</replaceable> will
contain the role the user has requested to log in as. The callback must
set output parameters in the <literal>result</literal> struct, which is
defined as below:
《機械翻訳》トークン
には、検証対象のベアラトークンが含まれます。
PostgreSQLでは、トークンが構文的に整形式であることが確認されましたが、他のバリデーションは実行されていません。
ロール
には、ユーザがログに要求したロールがとして含まれます。
コールバックはresult
構造体に出力パラメータを設定する必要があります。
これは次のように定義されます。
typedef struct ValidatorModuleResult { bool authorized; char *authn_id; } ValidatorModuleResult;
The connection will only proceed if the module sets
<structfield>result->authorized</structfield> to <literal>true</literal>. To
authenticate the user, the authenticated user name (as determined using the
token) shall be palloc'd and returned in the <structfield>result->authn_id</structfield>
field. Alternatively, <structfield>result->authn_id</structfield> may be set to
NULL if the token is valid but the associated user identity cannot be
determined.
《機械翻訳》モジュールがtrue
result->認証済に設定された場合のみ、コネクションが続行されます。
ユーザを認証するために、認証されたユーザ名前はresult->authn_id
トークンを使用して決定されたようにpallocされ、フィールドで返される必要があります。
または、result->authn_id
トークンが有効であるが、関連付けられたユーザIDを決定できない場合は、NULLに設定される場合があります。
A validator may return <literal>false</literal> to signal an internal error,
in which case any result parameters are ignored and the connection fails.
Otherwise the validator should return <literal>true</literal> to indicate
that it has processed the token and made an authorization decision.
《機械翻訳》バリデータは、内部エラーを結果false
シグナルに対してすることができます。
この場合、ケースではすべての結果パラメータが無視され、コネクションは失敗します。
そうでない場合、バリデータは結果true
トークンを処理し、許可決定を行ったことを示すする必要があります。
The behavior after <function>validate_cb</function> returns depends on the
specific HBA setup. Normally, the <structfield>result->authn_id</structfield> user
name must exactly match the role that the user is logging in as. (This
behavior may be modified with a usermap.) But when authenticating against
an HBA rule with <literal>delegate_ident_mapping</literal> turned on,
<productname>PostgreSQL</productname> will not perform any checks on the value of
<structfield>result->authn_id</structfield> at all; in this case it is up to the
validator to ensure that the token carries enough privileges for the user to
log in under the indicated <replaceable>role</replaceable>.
《機械翻訳》validate_cb
returnsの後の動作は、特定のHBAセットアップによって異なります。
通常、result->authn_id
ユーザ名前は、ユーザがロギングとしているロールを正確にマッチする必要があります。
(この動作はユーザマップで変更できます。)
しかし、delegate_ident_mapping
オンでHBAルールに対して認証する場合、PostgreSQLはresult->authn_id
の値をまったくチェックしません。
このケースでは、トークンが指示されたrole
の下でユーザがログに対して十分な権限を持つかどうかは、バリデータから保証に委ねられます。
The <function>shutdown_cb</function> callback is executed when the backend
process associated with the connection exits. If the validator module has
any allocated state, this callback should free it to avoid resource leaks.
《機械翻訳》shutdown_cb
コールバックは、コネクションに関連付けられたバックエンドプロセスが終了するときに実行されます。
バリデータモジュールに割り当てられた状態がある場合、このコールバックはリソースリークを回避するためにフリーする必要があります。
typedef void (*ValidatorShutdownCB) (ValidatorModuleState *state);