> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/server-programming/oauth-validators.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 第 50 章 OAuth 驗證器模組

### 第 50 章 OAuth 驗證器模組

**目錄**

* [50.1. 安全地設計驗證器模組](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-design.md)
  * [50.1.1. 驗證器的職責](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-design.md#oauth-validator-design-responsibilities)
  * [50.1.2. 一般撰碼準則](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-design.md#oauth-validator-design-guidelines)
  * [50.1.3. 授權使用者（使用者對應委派）](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-design.md#oauth-validator-design-usermap-delegation)
* [50.2. 初始化函式](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-init.md)
* [50.3. OAuth 驗證器回呼函式](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-callbacks.md)
  * [50.3.1. 啟動回呼](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-callbacks.md#oauth-validator-callback-startup)
  * [50.3.2. 驗證回呼](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-callbacks.md#oauth-validator-callback-validate)
  * [50.3.3. 關閉回呼](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-callbacks.md#oauth-validator-callback-shutdown)

PostgreSQL 提供了一套基礎架構，可用來建立自訂模組，對 OAuth 持有者權杖執行伺服器端驗證。由於 OAuth 的實作方式差異極大，而持有者權杖的驗證方式又高度依賴於發行方，因此伺服器本身無法自行檢查權杖；驗證器模組提供了伺服器與所使用之 OAuth 提供者之間的整合層。

OAuth 驗證器模組至少必須包含一個初始化函式（見[第 50.2 節](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-init.md)），以及執行驗證所需的回呼函式（見[第 50.3.2 節](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-callbacks.md#oauth-validator-callback-validate)）。

#### 警告

由於行為異常的驗證器可能讓未經授權的使用者進入資料庫，因此正確的實作方式對伺服器的安全至關重要。設計考量請參閱[第 50.1 節](https://docs.postgresql.tw/19/server-programming/oauth-validators/oauth-validator-design.md)。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/oauth-validators.html)（原文版本：18.6；核對日期：2026-09-15）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/server-programming/oauth-validators.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
