Fetch User Keys - simple tool for fetching SSH keys from various sources

ft: replace `forge` source with `http` source

hauleth.dev 2f485abf db5731db

verified
Changed files
+15 -20
cli
src
sources
docs
+10 -13
cli/src/sources/mod.rs
···
pub enum Source {
Raw(Raw),
Hosts(Hosts),
-
Forge(Forge),
+
Http(Http),
Github(String),
Sourcehut(String),
Gitlab(String),
···
match *self {
Source::Raw(ref raw) => raw.fetch().await,
Source::Hosts(ref raw) => raw.fetch().await,
-
Source::Forge(ref raw) => raw.fetch().await,
-
Source::Github(ref user) => Forge { user: user.clone(), host: "github.com".into() }.fetch().await,
-
Source::Sourcehut(ref user) => Forge { user: user.clone(), host: "meta.sr.ht".into() }.fetch().await,
-
Source::Gitlab(ref user) => Forge { user: user.clone(), host: "gitlab.com".into() }.fetch().await,
-
Source::Codeberg(ref user) => Forge { user: user.clone(), host: "codeberg.org".into() }.fetch().await,
+
Source::Http(ref raw) => raw.fetch().await,
+
Source::Github(ref user) => Http { url: format!("https://github.com/{user}.keys") }.fetch().await,
+
Source::Sourcehut(ref user) => Http { url: format!("https://meta.sr.ht/{user}.keys") }.fetch().await,
+
Source::Gitlab(ref user) => Http { url: format!("https://gitlab.com/{user}.keys") }.fetch().await,
+
Source::Codeberg(ref user) => Http { url: format!("https://codeberg.org/{user}.keys") }.fetch().await,
}
}
}
···
}
#[derive(Debug, Deserialize)]
-
pub struct Forge {
-
pub user: String,
-
pub host: String,
+
pub struct Http {
+
pub url: String
}
#[async_trait]
-
impl Fetch for Forge {
+
impl Fetch for Http {
async fn fetch(&self) -> Vec<PublicKey> {
-
let url = format!("https://{}/{}.keys", self.host, self.user);
-
-
reqwest::get(url)
+
reqwest::get(&self.url)
.await
.unwrap()
.text()
+5 -7
docs/fuk.1.scd
···
*host*
Hostnames that will be passed to _ssh-keyscan_(1).
-
*forge*
-
Takes map as an argument, that map must have 2 keys, _user_ which will
-
be the name of the user used for querying and _host_ which will be the
-
host that will be queried. The resulting URL will be constructed as
-
_https://{host}/{user}.keys_.
+
*http*
+
Takes `url` as and argument, with URL pointing to the HTTP resource that
+
will contain SSH keys.
*github*, *gitlab*, *sourcehut*, *codeberg*
-
Each of these are shortcuts for *forge* entries to provide default
-
_host_ for equivalent entries. In order these would be _github.com_,
+
Each of these are shortcuts for *http* entries to provide default
+
_url_ for equivalent entries. In order these would be _github.com_,
_gitlab.com_, _meta.sr.ht_, and _codeberg.org_.
Example configuration: