{"Entry":{"collection":"conn","key":"require-auth","name":"require_auth","aliases":["PGREQUIREAUTH","require_auth"],"metadata":{"aliases":["PGREQUIREAUTH","require_auth"],"category":"Authentication","content_hash":"240b90d1a88d25548e832311df57677654551b77d70a0519a17baa80e1f2cb9a","derived_content_hash":"6811b95bbe1c76c61713aa9e33d1d9c7303977b5f96eb86ae021b5df8b2e8a96","documentation_refresh":{"batch":"20261113","original_source_rev":"","versions":{"16":"16.16","17":"17.12","18":"18.7","19":"19rc2"}},"imported_at":"2026-09-30T00:40:35.049452+08:00","name":"require_auth","name_zh":"","slug":"require-auth","summary":"Specifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether."}},"Definition":{"Collection":"conn","Key":"require-auth","SourceDatabase":"center","Version":"18","SourceTable":"connection_parameter","SourceKey":"require-auth","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","Facts":{"comparison_data":{"compiled_default_expression":"NULL","default_evidence":["Specifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether."],"definition":"Specifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether. Methods may be negated with the addition of a ! prefix, in which case the server must not attempt the listed method; any other method is accepted, and the server is free not to authenticate the client at all. If a comma-separated list is provided, the server may not attempt any of the listed negated methods. Negated and non-negated forms may not be combined in the same setting. As a final special case, the none method requires the server not to use an authentication challenge. (It may also be negated, to require some form of authentication.) The following methods may be specified: password The server must request plaintext password authentication. md5 The server must request MD5 hashed password authentication. Warning Support for MD5-encrypted passwords is deprecated and will be removed in a future release of PostgreSQL . Refer to Section 20.5 for details about migrating to another password type. gss The server must either request a Kerberos handshake via GSSAPI or establish a GSS -encrypted channel (see also gssencmode ). sspi The server must request Windows SSPI authentication. scram-sha-256 The server must successfully complete a SCRAM-SHA-256 authentication exchange with the client. oauth The server must request an OAuth bearer token from the client. none The server must not prompt the client for an authentication exchange. (This does not prohibit client certificate authentication via TLS, nor GSS authentication via its encrypted transport.)","documented":true,"environment":"PGREQUIREAUTH","keyword":"require_auth"},"comparison_hash":"b90f10c3c2ccff2990774577cab21e0392f308768058f40109dd55f7e52ca3c5","default_evidence":["Specifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether."],"description":["Specifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether."],"description_zh":"指定客户端要求服务器采用的认证方法。如果服务器没有使用所要求的方法来认证客户端，或者服务器没有完整完成认证握手，则连接将失败。也可以提供一个以逗号分隔的方法列表，此时服务器必须恰好使用其中一种方法，连接才会成功。默认情况下接受任意认证方法，并且服务器也可以完全跳过认证。 可以在方法名前加上 ! 前缀以表示否定，此时服务器 不得 尝试所列方法；除此之外，任何其他方法都可接受，并且服务器也可以完全不认证客户端。如果提供的是逗号分隔列表，服务器不得尝试其中 任何一个 被否定的方法。否定形式和非否定形式不能在同一设置中混用。 最后还有一种特殊情况： none 方法要求服务器不使用认证质询。（它也可以被否定，用来要求必须进行某种认证。） 可指定的方法如下： password 服务器必须请求明文密码认证。 md5 服务器必须请求 MD5 hash 密码认证。 警告 对 MD5 加密密码的支持已弃用，并将在 PostgreSQL 的未来版本中移除。迁移到其他密码类型的详细信息见 第 20.5 节 。 gss 服务器必须通过 GSSAPI 请求 Kerberos 握手，或者建立一个经过 GSS 加密的通道（另见 gssencmode ）。 sspi 服务器必须请求 Windows SSPI 认证。 scram-sha-256 服务器必须与客户端成功完成一次 SCRAM-SHA-256 认证交换。 oauth 服务器必须向客户端请求 OAuth Bearer 令牌。 none 服务器不得提示客户端执行认证交换。（这并不禁止通过 TLS 进行客户端证书认证，也不禁止通过 GSS 自身的加密传输进行 GSS 认证。）","description_zh_html":"\u003cp\u003e连接参数 require_auth。\u003c/p\u003e\u003ch3\u003e同版本中文手册定义\u003c/h3\u003e\u003cdd\u003e\u003cp\u003e\n        指定客户端要求服务器采用的认证方法。如果服务器没有使用所要求的方法来认证客户端，或者服务器没有完整完成认证握手，则连接将失败。也可以提供一个以逗号分隔的方法列表，此时服务器必须恰好使用其中一种方法，连接才会成功。默认情况下接受任意认证方法，并且服务器也可以完全跳过认证。\n       \u003c/p\u003e\u003cp\u003e\n        可以在方法名前加上\u003ccode class=\"literal\"\u003e!\u003c/code\u003e前缀以表示否定，此时服务器\u003cspan class=\"emphasis\"\u003e\u003cem\u003e不得\u003c/em\u003e\u003c/span\u003e尝试所列方法；除此之外，任何其他方法都可接受，并且服务器也可以完全不认证客户端。如果提供的是逗号分隔列表，服务器不得尝试其中\u003cspan class=\"emphasis\"\u003e\u003cem\u003e任何一个\u003c/em\u003e\u003c/span\u003e被否定的方法。否定形式和非否定形式不能在同一设置中混用。\n       \u003c/p\u003e\u003cp\u003e\n        最后还有一种特殊情况：\u003ccode class=\"literal\"\u003enone\u003c/code\u003e 方法要求服务器不使用认证质询。（它也可以被否定，用来要求必须进行某种认证。）\n       \u003c/p\u003e\u003cp\u003e\n        可指定的方法如下：\n\n        \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epassword\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            服务器必须请求明文密码认证。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003emd5\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            服务器必须请求 MD5 hash 密码认证。\n           \u003c/p\u003e\u003cdiv class=\"warning\"\u003e\u003ch3 class=\"title\"\u003e警告\u003c/h3\u003e\u003cp\u003e对 MD5 加密密码的支持已弃用，并将在 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 的未来版本中移除。迁移到其他密码类型的详细信息见\u003ca class=\"xref\" href=\"/zh/docs/18/auth-password.html\"\u003e第 20.5 节\u003c/a\u003e。\u003c/p\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003egss\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            服务器必须通过 \u003cacronym class=\"acronym\"\u003eGSSAPI\u003c/acronym\u003e 请求 Kerberos 握手，或者建立一个经过 \u003cacronym class=\"acronym\"\u003eGSS\u003c/acronym\u003e 加密的通道（另见 \u003ca class=\"xref\" href=\"/zh/docs/18/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE\"\u003egssencmode\u003c/a\u003e）。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003esspi\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            服务器必须请求 Windows \u003cacronym class=\"acronym\"\u003eSSPI\u003c/acronym\u003e 认证。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            服务器必须与客户端成功完成一次 SCRAM-SHA-256 认证交换。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eoauth\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            服务器必须向客户端请求 OAuth Bearer 令牌。\n           \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003enone\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n            服务器不得提示客户端执行认证交换。（这并不禁止通过 TLS 进行客户端证书认证，也不禁止通过 GSS 自身的加密传输进行 GSS 认证。）\n           \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/dd\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/libpq-connect.html#LIBPQ-CONNECT-REQUIRE-AUTH\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e","documented":true,"environment":[{"description":"PGREQUIREAUTH behaves the same as the require_auth connection parameter.","name":"PGREQUIREAUTH","source_url":"/docs/18/libpq-envars.html"}],"facts":[{"label":"Client library","value":"libpq 18.6"},{"label":"Manual definition","value":"Documented"},{"label":"Source environment fallback","value":"PGREQUIREAUTH"},{"label":"Compiled fallback expression","value":"NULL"}],"facts_zh":[{"label":"客户端库","value":"libpq 18.6"},{"label":"手册定义","value":"手册已记载"},{"label":"源码中的环境变量回退","value":"PGREQUIREAUTH"},{"label":"编译时回退表达式","value":"NULL"}],"keyword":"require_auth","manual_html":"\u003cdiv\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt id=\"LIBPQ-CONNECT-REQUIRE-AUTH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003erequire_auth\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eSpecifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether.\u003c/p\u003e\n\u003cp\u003eMethods may be negated with the addition of a \u003ccode class=\"literal\"\u003e!\u003c/code\u003e prefix, in which case the server must \u003cspan class=\"emphasis\"\u003e\u003cem\u003enot\u003c/em\u003e\u003c/span\u003e attempt the listed method; any other method is accepted, and the server is free not to authenticate the client at all. If a comma-separated list is provided, the server may not attempt \u003cspan class=\"emphasis\"\u003e\u003cem\u003eany\u003c/em\u003e\u003c/span\u003e of the listed negated methods. Negated and non-negated forms may not be combined in the same setting.\u003c/p\u003e\n\u003cp\u003eAs a final special case, the \u003ccode class=\"literal\"\u003enone\u003c/code\u003e method requires the server not to use an authentication challenge. (It may also be negated, to require some form of authentication.)\u003c/p\u003e\n\u003cp\u003eThe following methods may be specified:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epassword\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request plaintext password authentication.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003emd5\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request MD5 hashed password authentication.\u003c/p\u003e\n\u003cdiv class=\"warning\"\u003e\n\u003ch3 class=\"title\"\u003eWarning\u003c/h3\u003e\n\u003cp\u003eSupport for MD5-encrypted passwords is deprecated and will be removed in a future release of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e. Refer to \u003ca class=\"xref\" href=\"/docs/18/auth-password.html\" title=\"20.5. Password Authentication\"\u003eSection 20.5\u003c/a\u003e for details about migrating to another password type.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003egss\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must either request a Kerberos handshake via GSSAPI or establish a GSS-encrypted channel (see also \u003ca class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE\"\u003egssencmode\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003esspi\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request Windows SSPI authentication.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must successfully complete a SCRAM-SHA-256 authentication exchange with the client.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eoauth\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request an OAuth bearer token from the client.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003enone\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must not prompt the client for an authentication exchange. (This does not prohibit client certificate authentication via TLS, nor GSS authentication via its encrypted transport.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","manual_path":"libpq-connect.html#LIBPQ-CONNECT-REQUIRE-AUTH","precedence_evidence":["The following environment variables can be used to select default connection parameter values, which will be used by PQconnectdb , PQsetdbLogin and PQsetdb if no value is directly specified by the calling code. These are useful to avoid hard-coding database connection information into simple client applications, for example.","Service names can be defined in either a per-user service file or a system-wide file. If the same service name exists in both the user and the system file, the user file takes precedence. By default, the per-user service file is named ~/.pg_service.conf . On Microsoft Windows, it is named %APPDATA%\\postgresql\\.pg_service.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile). A different file name can be specified by setting the environment variable PGSERVICEFILE . The system-wide file is named pg_service.conf . By default it is sought in the etc directory of the PostgreSQL installation (use pg_config --sysconfdir to identify this directory precisely). Another directory, but not a different file name, can be specified by setting the environment variable PGSYSCONFDIR .","Connection parameters obtained from a service file are combined with parameters obtained from other sources. A service file setting overrides the corresponding environment variable, and in turn can be overridden by a value given directly in the connection string. For example, using the above service file, a connection string service=mydb port=5434 will use host somehost , port 5434 , user admin , and other parameters as set by environment variables or built-in defaults."],"related":[{"label":"Connection service file","url":"/docs/18/libpq-pgservice.html"},{"label":"Password file","url":"/docs/18/libpq-pgpass.html"},{"label":"All libpq environment variables","url":"/docs/18/libpq-envars.html"}],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[{"paragraphs":["The following environment variables can be used to select default connection parameter values, which will be used by PQconnectdb , PQsetdbLogin and PQsetdb if no value is directly specified by the calling code. These are useful to avoid hard-coding database connection information into simple client applications, for example.","Service names can be defined in either a per-user service file or a system-wide file. If the same service name exists in both the user and the system file, the user file takes precedence. By default, the per-user service file is named ~/.pg_service.conf . On Microsoft Windows, it is named %APPDATA%\\postgresql\\.pg_service.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile). A different file name can be specified by setting the environment variable PGSERVICEFILE . The system-wide file is named pg_service.conf . By default it is sought in the etc directory of the PostgreSQL installation (use pg_config --sysconfdir to identify this directory precisely). Another directory, but not a different file name, can be specified by setting the environment variable PGSYSCONFDIR .","Connection parameters obtained from a service file are combined with parameters obtained from other sources. A service file setting overrides the corresponding environment variable, and in turn can be overridden by a value given directly in the connection string. For example, using the above service file, a connection string service=mydb port=5434 will use host somehost , port 5434 , user admin , and other parameters as set by environment variables or built-in defaults."],"title":"Default resolution and service-file precedence"},{"paragraphs":["PGREQUIREAUTH behaves the same as the require_auth connection parameter."],"title":"Environment variable evidence"}],"sections_zh":[{"paragraphs":["以下环境变量可用于选择连接参数的默认值，供 PQconnectdb 、 PQsetdbLogin 和 PQsetdb 在调用代码未直接指定参数值时使用。例如，这样可以避免在简单的客户端应用程序中硬编码数据库连接信息。","服务名称可以在每个用户的服务文件或系统范围的文件中定义。如果同一个服务名称存在于用户文件和系统文件中，则用户文件优先。默认情况下，每个用户的服务文件名为 ~/.pg_service.conf 。在Microsoft Windows上，它的名称为 %APPDATA%\\postgresql\\.pg_service.conf （其中 %APPDATA% 指用户配置文件夹中的应用数据子目录）。可以通过设置环境变量 PGSERVICEFILE 来指定不同的文件名。系统范围的文件名为 pg_service.conf 。默认情况下，在 PostgreSQL 安装的 etc 目录中寻找（使用 pg_config --sysconfdir 来准确识别此目录）。可以通过设置环境变量 PGSYSCONFDIR 来指定另一个目录，但不能指定不同的文件名。","从服务文件中获取的连接参数会与其他来源的参数合并。服务文件中的设置会覆盖相应的环境变量，而连接字符串中直接给出的值又会覆盖服务文件中的设置。例如，使用上述服务文件时，连接字符串 service=mydb port=5434 将使用主机 somehost 、端口 5434 、用户 admin ，以及由环境变量或内置默认值设置的其他参数。"],"title":"默认值解析与服务文件优先级"},{"paragraphs":["PGREQUIREAUTH 的行为与 require_auth 连接参数相同。"],"title":"环境变量证据"}],"signature":"require_auth","source_option":{"compiled_default_expression":"NULL","declaration":"\"require_auth\", \"PGREQUIREAUTH\", NULL, NULL, \"Require-Auth\", \"\", 14, offsetof(struct pg_conn, require_auth)","environment":"PGREQUIREAUTH","keyword":"require_auth","source_notes":[]},"sources":[{"anchor":"LIBPQ-CONNECT-REQUIRE-AUTH","file":"libpq-connect.html","label":"18.6 English manual · libpq-connect.html","sha256":"c26a7fc3dcda6066cfe540641ae2690faf3d3c03277f30b4dfc2328ab45c212f","url":"/docs/18/libpq-connect.html#LIBPQ-CONNECT-REQUIRE-AUTH"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","file":"src/interfaces/libpq/fe-connect.c","label":"18.6 libpq connection option declarations","sha256":"44a6e386cbfd67ebe768d6ef5493098119c2e6b4796239d53e5ed7b122b206a5","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"anchor":"","file":"libpq-envars.html","label":"18.6 English manual · libpq-envars.html","sha256":"d64db73f3d48127bb984a5f775e77b7bcca2ba4bd218333cf24a45fcdd7c4363","url":"/docs/18/libpq-envars.html"},{"anchor":"","file":"libpq-pgservice.html","label":"18.6 English manual · libpq-pgservice.html","sha256":"6035a3f0ee1d0fd80db5bf58834390b884eecd23206659bdf6f07560deea5aa7","url":"/docs/18/libpq-pgservice.html"}],"tables":[{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Documented behavior"}],"key":"environment","rows":[{"description":"PGREQUIREAUTH behaves the same as the require_auth connection parameter.","name":{"text":"PGREQUIREAUTH","url":"/docs/18/libpq-envars.html"}}],"title":"Environment fallback"}],"tables_zh":[{"columns":[{"key":"name","label":"变量"},{"key":"description","label":"手册记载的行为"}],"key":"environment","rows":[{"description":"PGREQUIREAUTH 的行为与 require_auth 连接参数相同。","name":{"text":"PGREQUIREAUTH","url":"/docs/18/libpq-envars.html"}}],"title":"环境变量回退"}],"zh_from":{"authored_translation":"source-derived-identity","body_sha256":"93e26ded09be2fd4b226758e51585bdddc4f6447c47a20bcbb809a378bf3f9f6","kind":"same-version-chinese-manual-with-source-derived-identity","manual":{"anchor":"LIBPQ-CONNECT-REQUIRE-AUTH","build_id":107,"extraction":"exact-definition","fragment_sha256":"8cd882a1e63c07d2ad8d99c66463d1acef7d97829746b0fb05404148a5780c1f","locale":"zh-Hans","page_key":"libpq-connect.html","source_hash":"1555b03a2bc480920a9c72be9683ee3ddf99e8a5c17267c0dca73c42cd50e44c","source_revision":"unknown:rendered-translation-baseline","translated_from_revision":null,"translation_revision":"git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b","url":"/zh/docs/18/libpq-connect.html#LIBPQ-CONNECT-REQUIRE-AUTH","version":"18"},"runtime_rerun":false,"source_facts_revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8"}},"ManualEvidence":{"manual_path":"libpq-connect.html#LIBPQ-CONNECT-REQUIRE-AUTH","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"LIBPQ-CONNECT-REQUIRE-AUTH","file":"libpq-connect.html","label":"18.6 English manual · libpq-connect.html","sha256":"c26a7fc3dcda6066cfe540641ae2690faf3d3c03277f30b4dfc2328ab45c212f","url":"/docs/18/libpq-connect.html#LIBPQ-CONNECT-REQUIRE-AUTH"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","file":"src/interfaces/libpq/fe-connect.c","label":"18.6 libpq connection option declarations","sha256":"44a6e386cbfd67ebe768d6ef5493098119c2e6b4796239d53e5ed7b122b206a5","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"anchor":"","file":"libpq-envars.html","label":"18.6 English manual · libpq-envars.html","sha256":"d64db73f3d48127bb984a5f775e77b7bcca2ba4bd218333cf24a45fcdd7c4363","url":"/docs/18/libpq-envars.html"},{"anchor":"","file":"libpq-pgservice.html","label":"18.6 English manual · libpq-pgservice.html","sha256":"6035a3f0ee1d0fd80db5bf58834390b884eecd23206659bdf6f07560deea5aa7","url":"/docs/18/libpq-pgservice.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"conn","Key":"require-auth","SourceDatabase":"center","Version":"18","Locale":"en","Title":"require_auth","Summary":"Specifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether.","BodyHTML":"\u003cdiv\u003e\u003cdl\u003e\u003cdt id=\"LIBPQ-CONNECT-REQUIRE-AUTH\"\u003e\u003cspan\u003e\u003ccode\u003erequire_auth\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eSpecifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether.\u003c/p\u003e\n\u003cp\u003eMethods may be negated with the addition of a \u003ccode\u003e!\u003c/code\u003e prefix, in which case the server must \u003cspan\u003e\u003cem\u003enot\u003c/em\u003e\u003c/span\u003e attempt the listed method; any other method is accepted, and the server is free not to authenticate the client at all. If a comma-separated list is provided, the server may not attempt \u003cspan\u003e\u003cem\u003eany\u003c/em\u003e\u003c/span\u003e of the listed negated methods. Negated and non-negated forms may not be combined in the same setting.\u003c/p\u003e\n\u003cp\u003eAs a final special case, the \u003ccode\u003enone\u003c/code\u003e method requires the server not to use an authentication challenge. (It may also be negated, to require some form of authentication.)\u003c/p\u003e\n\u003cp\u003eThe following methods may be specified:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003epassword\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request plaintext password authentication.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003emd5\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request MD5 hashed password authentication.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eWarning\u003c/h3\u003e\n\u003cp\u003eSupport for MD5-encrypted passwords is deprecated and will be removed in a future release of \u003cspan\u003ePostgreSQL\u003c/span\u003e. Refer to \u003ca href=\"/docs/18/auth-password.html\" rel=\"nofollow\"\u003eSection 20.5\u003c/a\u003e for details about migrating to another password type.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003egss\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must either request a Kerberos handshake via GSSAPI or establish a GSS-encrypted channel (see also \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE\" rel=\"nofollow\"\u003egssencmode\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003esspi\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request Windows SSPI authentication.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003escram-sha-256\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must successfully complete a SCRAM-SHA-256 authentication exchange with the client.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eoauth\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request an OAuth bearer token from the client.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003enone\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must not prompt the client for an authentication exchange. (This does not prohibit client certificate authentication via TLS, nor GSS authentication via its encrypted transport.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"9bb0eb75597af243369d65a9aa63d0ce1328331945893ce412ed02bc8cc0d980","Payload":{"description":["Specifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether."],"manual_html":"\u003cdiv\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt id=\"LIBPQ-CONNECT-REQUIRE-AUTH\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003erequire_auth\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\n\u003cp\u003eSpecifies the authentication method that the client requires from the server. If the server does not use the required method to authenticate the client, or if the authentication handshake is not fully completed by the server, the connection will fail. A comma-separated list of methods may also be provided, of which the server must use exactly one in order for the connection to succeed. By default, any authentication method is accepted, and the server is free to skip authentication altogether.\u003c/p\u003e\n\u003cp\u003eMethods may be negated with the addition of a \u003ccode class=\"literal\"\u003e!\u003c/code\u003e prefix, in which case the server must \u003cspan class=\"emphasis\"\u003e\u003cem\u003enot\u003c/em\u003e\u003c/span\u003e attempt the listed method; any other method is accepted, and the server is free not to authenticate the client at all. If a comma-separated list is provided, the server may not attempt \u003cspan class=\"emphasis\"\u003e\u003cem\u003eany\u003c/em\u003e\u003c/span\u003e of the listed negated methods. Negated and non-negated forms may not be combined in the same setting.\u003c/p\u003e\n\u003cp\u003eAs a final special case, the \u003ccode class=\"literal\"\u003enone\u003c/code\u003e method requires the server not to use an authentication challenge. (It may also be negated, to require some form of authentication.)\u003c/p\u003e\n\u003cp\u003eThe following methods may be specified:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003epassword\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request plaintext password authentication.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003emd5\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request MD5 hashed password authentication.\u003c/p\u003e\n\u003cdiv class=\"warning\"\u003e\n\u003ch3 class=\"title\"\u003eWarning\u003c/h3\u003e\n\u003cp\u003eSupport for MD5-encrypted passwords is deprecated and will be removed in a future release of \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e. Refer to \u003ca class=\"xref\" href=\"/docs/18/auth-password.html\" title=\"20.5. Password Authentication\"\u003eSection 20.5\u003c/a\u003e for details about migrating to another password type.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003egss\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must either request a Kerberos handshake via GSSAPI or establish a GSS-encrypted channel (see also \u003ca class=\"xref\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNECT-GSSENCMODE\"\u003egssencmode\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003esspi\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request Windows SSPI authentication.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003escram-sha-256\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must successfully complete a SCRAM-SHA-256 authentication exchange with the client.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eoauth\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must request an OAuth bearer token from the client.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003enone\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe server must not prompt the client for an authentication exchange. (This does not prohibit client certificate authentication via TLS, nor GSS authentication via its encrypted transport.)\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","related":[{"label":"Connection service file","url":"/docs/18/libpq-pgservice.html"},{"label":"Password file","url":"/docs/18/libpq-pgpass.html"},{"label":"All libpq environment variables","url":"/docs/18/libpq-envars.html"}],"sections":[{"paragraphs":["The following environment variables can be used to select default connection parameter values, which will be used by PQconnectdb , PQsetdbLogin and PQsetdb if no value is directly specified by the calling code. These are useful to avoid hard-coding database connection information into simple client applications, for example.","Service names can be defined in either a per-user service file or a system-wide file. If the same service name exists in both the user and the system file, the user file takes precedence. By default, the per-user service file is named ~/.pg_service.conf . On Microsoft Windows, it is named %APPDATA%\\postgresql\\.pg_service.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile). A different file name can be specified by setting the environment variable PGSERVICEFILE . The system-wide file is named pg_service.conf . By default it is sought in the etc directory of the PostgreSQL installation (use pg_config --sysconfdir to identify this directory precisely). Another directory, but not a different file name, can be specified by setting the environment variable PGSYSCONFDIR .","Connection parameters obtained from a service file are combined with parameters obtained from other sources. A service file setting overrides the corresponding environment variable, and in turn can be overridden by a value given directly in the connection string. For example, using the above service file, a connection string service=mydb port=5434 will use host somehost , port 5434 , user admin , and other parameters as set by environment variables or built-in defaults."],"title":"Default resolution and service-file precedence"},{"paragraphs":["PGREQUIREAUTH behaves the same as the require_auth connection parameter."],"title":"Environment variable evidence"}],"tables":[{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Documented behavior"}],"key":"environment","rows":[{"description":"PGREQUIREAUTH behaves the same as the require_auth connection parameter.","name":{"text":"PGREQUIREAUTH","url":"/docs/18/libpq-envars.html"}}],"title":"Environment fallback"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
