turboflakes / crunch

Crunch is a command-line interface (CLI) and Matrix Bot to claim staking rewards every Era for Substrate-based chains
https://turboflakes.io
Apache License 2.0
63 stars 22 forks source link

Authentification for stashes from remote url (Feature request) #17

Closed ScepticMatt closed 2 years ago

ScepticMatt commented 2 years ago

in this function for remote url

pub async fn try_fetch_stashes_from_remote_url(
) -> Result<Option<Vec<String>>, CrunchError> {
    let config = CONFIG.clone();
    if config.stashes_url.len() == 0 {
        return Ok(None);
    }
    let response = reqwest::get(&config.stashes_url).await?.text().await?;
    let v: Vec<String> = response.split('\n').map(|s| s.to_string()).collect();
    if v.is_empty() {
        return Ok(None);
    }
    info!("{} stashes loaded from {}", v.len(), config.stashes_url);
    Ok(Some(v))
}

I would like to use some kind of authorization with this feature

e.g.

    [...]
    let client = Client::new();

    let user: Option<String> = &config.stashes_url_user;
    let password: Option<String> = &config.stashes_url_password;

    let response = client
        .get(&config.stashes_url)
        .basic_auth(user, password)
        .send();
   [...]
ScepticMatt commented 2 years ago

nevermind, remembered that you can include basic auth inside URL