Skip to content

Commit 32172c3

Browse files
committed
feat(config): Add CapabilitySshServerV1 to app config
Allows configuration of the SSH server behaviour for an app.
1 parent e40d947 commit 32172c3

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

lib/config/src/app/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ mod http;
55
mod job;
66
mod pretty_duration;
77
mod snapshot_trigger;
8+
mod ssh;
89

9-
pub use self::{healthcheck::*, http::*, job::*, pretty_duration::*, snapshot_trigger::*};
10+
pub use self::{healthcheck::*, http::*, job::*, pretty_duration::*, snapshot_trigger::*, ssh::*};
1011

1112
use anyhow::{bail, Context};
1213
use bytesize::ByteSize;
@@ -206,6 +207,8 @@ pub struct AppConfigCapabilityMapV1 {
206207
#[serde(skip_serializing_if = "Option::is_none")]
207208
pub instaboot: Option<AppConfigCapabilityInstaBootV1>,
208209

210+
pub ssh: Option<CapabilitySshServerV1>,
211+
209212
/// Additional unknown capabilities.
210213
///
211214
/// This provides a small bit of forwards compatibility for newly added

lib/config/src/app/ssh.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use indexmap::IndexMap;
2+
use schemars::JsonSchema;
3+
use serde::{Deserialize, Serialize};
4+
5+
/// Configure SSH server credentials and settings.
6+
#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug, PartialEq, Eq)]
7+
pub struct CapabilitySshServerV1 {
8+
/// Enable an SSH server.
9+
#[serde(default, skip_serializing_if = "Option::is_none")]
10+
pub enabled: Option<bool>,
11+
12+
#[serde(skip_serializing_if = "Option::is_none")]
13+
pub users: Option<Vec<SshUserV1>>,
14+
15+
/// Additional unknown fields.
16+
/// This provides a small bit of forwards compatibility.
17+
#[serde(flatten)]
18+
pub other: IndexMap<String, serde_json::Value>,
19+
}
20+
21+
#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
22+
pub struct SshUserV1 {
23+
/// The username used for SSH login.
24+
pub username: String,
25+
26+
/// Passwords for this user.
27+
#[serde(skip_serializing_if = "Option::is_none")]
28+
pub passwords: Option<Vec<PasswordV1>>,
29+
30+
/// SSH public keys for this user.
31+
#[serde(skip_serializing_if = "Option::is_none")]
32+
pub authorized_keys: Option<Vec<String>>,
33+
34+
/// Additional unknown fields.
35+
/// This provides a small bit of forwards compatibility.
36+
#[serde(flatten)]
37+
pub other: IndexMap<String, serde_json::Value>,
38+
}
39+
40+
#[derive(Serialize, Deserialize, JsonSchema, PartialEq, Eq, Clone, Debug)]
41+
#[serde(rename_all = "snake_case", tag = "type")]
42+
pub enum PasswordV1 {
43+
/// Plain text password.
44+
Plain { password: String },
45+
/// Bcrypt password hash.
46+
Bcrypt { hash: String },
47+
}

0 commit comments

Comments
 (0)