authenticate

fun authenticate(stream: PgStream, password: String?, channelBinding: ChannelBinding)

Authenticates the user with the PostgreSQL server using the provided credentials.

SCRAM-SHA-256 is the mechanism this driver is built around, with or without channel binding. A cleartext password is answered too, but only over an encrypted connection - see sendCleartextPassword for what that is worth and why the condition is there. MD5 is refused outright: PostgreSQL has deprecated it, and a driver that starts at 18 has no era to support it for.

Parameters

stream

The underlying PostgreSQL communication stream used for message exchange.

password

The password for the user, can be null if not required.

channelBinding

How hard to insist that the exchange be bound to the TLS channel.

Throws

If authentication fails, protocol is violated, or unsupported mechanism is requested.