pasejo 2026.2.22

passage re-implementation in Rust for teams
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// SPDX-FileCopyrightText: The pasejo Authors
// SPDX-License-Identifier: 0BSD

use std::env;

use crate::cli::environment_variables;

pub fn download_public_key(username: &str) -> anyhow::Result<String> {
    let gitlab_host =
        env::var(environment_variables::GITLAB_HOST).unwrap_or_else(|_| String::from("gitlab.com"));
    let key = ureq::get(format!("https://{gitlab_host}/{username}.keys"))
        .call()?
        .body_mut()
        .read_to_string()?;
    Ok(String::from(key.trim()))
}