mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 15:25:32 +00:00
fix: replace use of deprecated base64
functions
This commit is contained in:
parent
d43257e18a
commit
0f6c377c12
@ -9,6 +9,8 @@ use rand::Rng;
|
|||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use stringprep::saslprep;
|
use stringprep::saslprep;
|
||||||
|
|
||||||
|
use base64::prelude::{Engine as _, BASE64_STANDARD};
|
||||||
|
|
||||||
const GS2_HEADER: &str = "n,,";
|
const GS2_HEADER: &str = "n,,";
|
||||||
const CHANNEL_ATTR: &str = "c";
|
const CHANNEL_ATTR: &str = "c";
|
||||||
const USERNAME_ATTR: &str = "n";
|
const USERNAME_ATTR: &str = "n";
|
||||||
@ -48,7 +50,8 @@ pub(crate) async fn authenticate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// channel-binding = "c=" base64
|
// channel-binding = "c=" base64
|
||||||
let channel_binding = format!("{}={}", CHANNEL_ATTR, base64::encode(GS2_HEADER));
|
let mut channel_binding = format!("{}=", CHANNEL_ATTR);
|
||||||
|
BASE64_STANDARD.encode_string(GS2_HEADER, &mut channel_binding);
|
||||||
|
|
||||||
// "n=" saslname ;; Usernames are prepared using SASLprep.
|
// "n=" saslname ;; Usernames are prepared using SASLprep.
|
||||||
let username = format!("{}={}", USERNAME_ATTR, options.username);
|
let username = format!("{}={}", USERNAME_ATTR, options.username);
|
||||||
@ -144,12 +147,12 @@ pub(crate) async fn authenticate(
|
|||||||
mac.update(&auth_message.as_bytes());
|
mac.update(&auth_message.as_bytes());
|
||||||
|
|
||||||
// client-final-message = client-final-message-without-proof "," proof
|
// client-final-message = client-final-message-without-proof "," proof
|
||||||
let client_final_message = format!(
|
let mut client_final_message = format!(
|
||||||
"{client_final_message_wo_proof},{client_proof_attr}={client_proof}",
|
"{client_final_message_wo_proof},{client_proof_attr}=",
|
||||||
client_final_message_wo_proof = client_final_message_wo_proof,
|
client_final_message_wo_proof = client_final_message_wo_proof,
|
||||||
client_proof_attr = CLIENT_PROOF_ATTR,
|
client_proof_attr = CLIENT_PROOF_ATTR,
|
||||||
client_proof = base64::encode(&client_proof)
|
|
||||||
);
|
);
|
||||||
|
BASE64_STANDARD.encode_string(client_proof, &mut client_final_message);
|
||||||
|
|
||||||
stream.send(SaslResponse(&client_final_message)).await?;
|
stream.send(SaslResponse(&client_final_message)).await?;
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ use sqlx_core::bytes::{Buf, Bytes};
|
|||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::io::Decode;
|
use crate::io::Decode;
|
||||||
|
|
||||||
|
use base64::prelude::{Engine as _, BASE64_STANDARD};
|
||||||
|
|
||||||
// On startup, the server sends an appropriate authentication request message,
|
// On startup, the server sends an appropriate authentication request message,
|
||||||
// to which the frontend must reply with an appropriate authentication
|
// to which the frontend must reply with an appropriate authentication
|
||||||
// response message (such as a password).
|
// response message (such as a password).
|
||||||
@ -150,7 +152,7 @@ impl Decode<'_> for AuthenticationSaslContinue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
b's' => {
|
b's' => {
|
||||||
salt = base64::decode(value).map_err(Error::protocol)?;
|
salt = BASE64_STANDARD.decode(value).map_err(Error::protocol)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
@ -180,7 +182,7 @@ impl Decode<'_> for AuthenticationSaslFinal {
|
|||||||
let value = &item[2..];
|
let value = &item[2..];
|
||||||
|
|
||||||
if let b'v' = key {
|
if let b'v' = key {
|
||||||
verifier = base64::decode(value).map_err(Error::protocol)?;
|
verifier = BASE64_STANDARD.decode(value).map_err(Error::protocol)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user