ChannelBinding (authentication/sasl.rs)

neon · libs/proxy/postgres-protocol2/src/authentication/sasl.rs · rust · Apache-2.0
auth, Auth / Identity

Provides SASL-based authentication support for SCRAM-SHA-256 in Postgres.

// Source: https://github.com/neondatabase/neon | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
//! SASL-based authentication support.

use std::fmt::Write;
use std::{io, iter, mem, str};

use base64::Engine as _;
use base64::prelude::BASE64_STANDARD;
use hmac::{Hmac, Mac};
use rand::{self, Rng};
use sha2::digest::FixedOutput;
use sha2::{Digest, Sha256};
use tokio::task::yield_now;

const NONCE_LENGTH: usize = 24;

/// The identifier of the SCRAM-SHA-256 SASL authentication mechanism.
pub const SCRAM_SHA_256: &str = "SCRAM-SHA-256";
/// The identifier of the SCRAM-SHA-256-PLUS SASL authentication mechanism.
pub const SCRAM_SHA_256_PLUS: &str = "SCRAM-SHA-256-PLUS";

// since postg

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key