# 20. 使用者認證

當用戶端應用程序連線到資料庫伺服器時，它將指定要連線的 PostgreSQL 資料庫使用者名稱，這與以特定使用者身份登入到 Unix 伺服器的方式大致相同。在 SQL 環境中，有效的資料庫使用者名確定資料庫物件的存取權限 - 有關詳細訊息，請參閱[第 21 章](https://github.com/pgsql-tw/gitbook-docs/tree/67cc71691219133f37b9a33df9c691a2dd9c2642/tw/server-administration/21.-zi-liao-ku-jiao-se)。因此，限制哪些資料庫使用者可以進行連線是非常重要的。

## 注意

正如第 21 章所描述的，PostgreSQL 實際上是以「角色」的角度來管理權限的。在本章中，我們一直使用資料庫使用者來表示「具有 LOGIN 權限的角色」。

身份驗證是資料庫伺服器建立用戶端身份的過程，延伸確認用戶端應用程序（或執行用戶端應用程序的使用者）是否被允許以請求的資料庫使用者名稱進行連線。

PostgreSQL 提供了許多不同的用戶端身份驗證方法。用於驗證特定用戶端連線的方法可以根據（用戶端）主機位址、資料庫名稱和使用者名稱進行驗證。

PostgreSQL 資料庫使用者名稱在邏輯上與運行服務器的作業系統的使用者名稱是分開的。如果特定伺服器的所有用戶在伺服器的機器上也有帳戶，那麼分配與其作業系統用戶名搭配的資料庫用戶名是有意義的。但是，接受遠端連線的伺服器可能有許多沒有本地作業系統帳戶的資料庫用戶，在這種情況下，資料庫用戶名和作業系統用戶名之間不需要有所關連。


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.postgresql.tw/server-administration/client-authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
