mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
fix(gateway): trim whitespace from systemd credential (#10695)
Unix tools often write a newline at the end of a file. When using the file's contents as a token, they need to match byte-for-byte otherwise we cannot authenticate to the portal. To ensure that, we trim the content from the file before creating the `SecretString`.
This commit is contained in:
@@ -276,7 +276,7 @@ async fn read_systemd_credential(name: &str) -> Result<SecretString> {
|
||||
let path = PathBuf::from(creds_dir).join(name);
|
||||
let content = tokio::fs::read_to_string(&path).await?;
|
||||
|
||||
Ok(SecretString::new(content))
|
||||
Ok(SecretString::new(content.trim().to_owned()))
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
@@ -457,7 +457,7 @@ mod tests {
|
||||
let cred_path = temp_dir.path().join("FIREZONE_TOKEN");
|
||||
|
||||
// Write token to credential file
|
||||
std::fs::write(cred_path, "systemd-token").unwrap();
|
||||
std::fs::write(cred_path, "systemd-token\n").unwrap();
|
||||
|
||||
// Set CREDENTIALS_DIRECTORY environment variable
|
||||
unsafe {
|
||||
|
||||
Reference in New Issue
Block a user