Commit

Author:

Hash:

Timestamp:

+50 -1 +/-3 browse

Kevin Schoon [me@kevinschoon.com]

bffc707ead275429c5ac2a44f81d20d9cc90eee4

Sun, 18 May 2025 14:04:58 +0000 (6 months ago)

add support for specifying ssh keys in config
1diff --git a/Cargo.lock b/Cargo.lock
2index 2a8d76f..8658511 100644
3--- a/Cargo.lock
4+++ b/Cargo.lock
5 @@ -339,6 +339,7 @@ dependencies = [
6 "log",
7 "mime",
8 "mime_guess",
9+ "openssh-keys",
10 "plotters",
11 "quick-xml",
12 "rand",
13 @@ -2037,6 +2038,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
14 checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
15
16 [[package]]
17+ name = "md-5"
18+ version = "0.10.6"
19+ source = "registry+https://github.com/rust-lang/crates.io-index"
20+ checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
21+ dependencies = [
22+ "cfg-if",
23+ "digest",
24+ ]
25+
26+ [[package]]
27 name = "memchr"
28 version = "2.7.4"
29 source = "registry+https://github.com/rust-lang/crates.io-index"
30 @@ -2213,6 +2224,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
31 checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
32
33 [[package]]
34+ name = "openssh-keys"
35+ version = "0.6.4"
36+ source = "registry+https://github.com/rust-lang/crates.io-index"
37+ checksum = "abb830a82898b2ac17c9620ddce839ac3b34b9cb8a1a037cbdbfb9841c756c3e"
38+ dependencies = [
39+ "base64 0.21.7",
40+ "byteorder",
41+ "md-5",
42+ "sha2",
43+ "thiserror 1.0.69",
44+ ]
45+
46+ [[package]]
47 name = "openssl"
48 version = "0.10.71"
49 source = "registry+https://github.com/rust-lang/crates.io-index"
50 diff --git a/ayllu/Cargo.toml b/ayllu/Cargo.toml
51index 6e14742..8a4ebde 100644
52--- a/ayllu/Cargo.toml
53+++ b/ayllu/Cargo.toml
54 @@ -58,6 +58,7 @@ webfinger-rs = { version = "0.0.12", features = ["axum"] }
55
56 quick-xml = { version = "0.37.5", features = ["encoding"] }
57 askama = { version = "0.14.0" }
58+ openssh-keys = "0.6.4"
59
60 [build-dependencies]
61 cc="*"
62 diff --git a/ayllu/src/config.rs b/ayllu/src/config.rs
63index d7020be..8bc8b13 100644
64--- a/ayllu/src/config.rs
65+++ b/ayllu/src/config.rs
66 @@ -197,6 +197,30 @@ impl TreeSitter {
67 }
68 }
69
70+ #[derive(Clone, Debug)]
71+ pub struct PublicKey {
72+ inner: openssh_keys::PublicKey,
73+ }
74+
75+ impl Serialize for PublicKey {
76+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
77+ where
78+ S: serde::Serializer {
79+ self.inner.to_string().serialize(serializer)
80+ }
81+ }
82+
83+ impl<'de> Deserialize<'de> for PublicKey {
84+ fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
85+ where
86+ D: serde::Deserializer<'de>,
87+ {
88+ let key_str = String::deserialize(deserializer)?;
89+ let pub_key = openssh_keys::PublicKey::parse(&key_str).map_err(serde::de::Error::custom)?;
90+ Ok(PublicKey { inner: pub_key })
91+ }
92+ }
93+
94 #[derive(Deserialize, Serialize, Clone, Debug)]
95 pub struct Lfs {
96 pub url_template: String,
97 @@ -222,7 +246,7 @@ pub struct Author {
98 pub tagline: Option<String>,
99 pub avatar: Option<UrlLink>,
100 pub profiles: Option<Vec<UrlLink>>,
101- // TODO: PGP Keys, SSH Keys
102+ pub keys: Option<Vec<PublicKey>>,
103 }
104
105 #[derive(Deserialize, Serialize, Clone, Debug)]