Skip to content

Support multiple SASL auth mechanisms #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ impl Server {
Err(_) => return Err(Error::SocketError(format!("Error reading sasl message on server startup {{ username: {:?}, database: {:?} }}", user.username, database))),
};

let sasl_type = String::from_utf8_lossy(&sasl_auth[..sasl_len - 2]);
let sasl_types: Vec<_> = sasl_auth[..sasl_len - 2]
.split(|&b| b == 0)
.map(|v| String::from_utf8_lossy(v).to_string())
.collect();

if sasl_type == SCRAM_SHA_256 {
if sasl_types.contains(&SCRAM_SHA_256.to_string()) {
debug!("Using {}", SCRAM_SHA_256);

// Generate client message.
Expand All @@ -185,7 +188,7 @@ impl Server {

write_all(&mut stream, res).await?;
} else {
error!("Unsupported SCRAM version: {}", sasl_type);
error!("Unsupported SCRAM version: {:?}", sasl_types);
return Err(Error::ServerError);
}
}
Expand Down