pub struct UserRecord {
pub role: Role,
pub can_login: bool,
pub password_declared: bool,
pub inherit: bool,
pub superuser: bool,
/* private fields */
}Fields§
§role: Role§can_login: boolv7.39 (read01 round 58) — PG role attributes. CREATE USER is PG’s
CREATE ROLE … LOGIN; CREATE ROLE alone cannot log in but can hold
privileges and have members. Attributes are NEVER inherited through
membership (that is PG’s rule: only privileges flow, not attributes) —
a member of a superuser role must SET ROLE to it to act as one.
password_declared: boolv7.39 (round 548) — was a password actually DECLARED for this role?
A bare CREATE ROLE devs gets an unguessable credential derived
from its own salt (so no record ever carries an empty password),
which made “has a hash” useless for telling a real account from
a group role. The wire’s open-vs-authenticated decision needs
that distinction: it used to arm on ANY role existing, so
creating a NOLOGIN group role locked the operator out of their
own database — postgres has no password, so nothing could
connect afterwards and there was no way back through SQL.
inherit: boolINHERIT (the default): this role automatically holds the privileges of
every role it is a member of. NOINHERIT means it must SET ROLE to
them explicitly.
superuser: boolSUPERUSER: bypasses every privilege check.
Implementations§
Source§impl UserRecord
impl UserRecord
pub fn verify(&self, password: &str) -> bool
Sourcepub fn has_credentials(&self) -> bool
pub fn has_credentials(&self) -> bool
v7.39 (round 548) — can this role be authenticated at all?
A CREATE ROLE devs NOLOGIN records no password and cannot log
in. It used to count toward “this server has users, so demand a
password from everybody”, which locked the operator out of their
own database: postgres has no password, so after creating a
group role nothing could connect and there was no way back
through SQL.
pub const fn scram(&self) -> Option<&ScramSecrets>
Sourcepub const fn mysql_native(&self) -> Option<&[u8; 20]>
pub const fn mysql_native(&self) -> Option<&[u8; 20]>
v7.17.0 Phase 3.P0-71: borrow the stored
mysql_native_password verifier (SHA1(SHA1(password)))
for the MySQL-wire shim.
Sourcepub const fn caching_sha2(&self) -> Option<&[u8; 32]>
pub const fn caching_sha2(&self) -> Option<&[u8; 32]>
v7.17.0 Phase 3.P0-72: borrow the stored
caching_sha2_password verifier (SHA256(SHA256(password)))
for the MySQL-wire shim’s fast-path auth.
Sourcepub fn verify_caching_sha2_password(
&self,
scramble: &[u8],
client_response: &[u8],
) -> bool
pub fn verify_caching_sha2_password( &self, scramble: &[u8], client_response: &[u8], ) -> bool
v7.17.0 Phase 3.P0-72 — verify a client
caching_sha2_password fast-path response.
Protocol: same XOR shape as mysql_native_password but
with SHA-256 instead of SHA-1:
client_response = SHA256(password) XOR SHA256(scramble || SHA256(SHA256(password))). Server reconstructs and
checks SHA256(reconstructed) == stored_hash.
Full-auth RSA fallback (when the cache misses) is a v7.18 carve-out — clients connecting over plaintext without a cached entry will see Access Denied from the shim until that lands.
Sourcepub fn verify_mysql_native_password(
&self,
scramble: &[u8],
client_response: &[u8],
) -> bool
pub fn verify_mysql_native_password( &self, scramble: &[u8], client_response: &[u8], ) -> bool
v7.17.0 Phase 3.P0-71 — verify a client
mysql_native_password auth response.
Protocol: the client sends a 20-byte response
client_proof = SHA1(password) XOR SHA1(scramble || SHA1(SHA1(password))). The server reconstructs
SHA1(password) = client_proof XOR SHA1(scramble || stored_hash) and verifies SHA1(reconstructed) == stored_hash. Returns false if the user has no stored
hash (loaded from a pre-v7.17 snapshot — the operator
has to reset the password to re-populate it).
Trait Implementations§
Source§impl Clone for UserRecord
impl Clone for UserRecord
Source§fn clone(&self) -> UserRecord
fn clone(&self) -> UserRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more