Struct postgres_protocol::authentication::sasl::ScramSha256

source ·
pub struct ScramSha256 { /* private fields */ }
Expand description

A type which handles the client side of the SCRAM-SHA-256/SCRAM-SHA-256-PLUS authentication process.

During the authentication process, if the backend sends an AuthenticationSASL message which includes SCRAM-SHA-256 as an authentication mechanism, this type can be used.

After a ScramSha256 is constructed, the buffer returned by the message() method should be sent to the backend in a SASLInitialResponse message along with the mechanism name.

The server will reply with an AuthenticationSASLContinue message. Its contents should be passed to the update() method, after which the buffer returned by the message() method should be sent to the backend in a SASLResponse message.

The server will reply with an AuthenticationSASLFinal message. Its contents should be passed to the finish() method, after which the authentication process is complete.

Implementations§

source§

impl ScramSha256

source

pub fn new(password: &[u8], channel_binding: ChannelBinding) -> ScramSha256

Constructs a new instance which will use the provided password for authentication.

source

pub fn message(&self) -> &[u8]

Returns the message which should be sent to the backend in an SASLResponse message.

source

pub fn update(&mut self, message: &[u8]) -> Result<()>

Updates the state machine with the response from the backend.

This should be called when an AuthenticationSASLContinue message is received.

source

pub fn finish(&mut self, message: &[u8]) -> Result<()>

Finalizes the authentication process.

This should be called when the backend sends an AuthenticationSASLFinal message. Authentication has only succeeded if this method returns Ok(()).

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V