Skip to content

Commit 2d69148

Browse files
authored
Merge pull request #5689 from wasmerio/run-704-add-ssh-settings-to-app-config
feat(config): Add CapabilitySshServerV1 to app config
2 parents e75a5e0 + af28aa2 commit 2d69148

File tree

3 files changed

+159
-1
lines changed

3 files changed

+159
-1
lines changed

docs/schema/generated/jsonschema/types/AppConfigV1.schema.json

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@
218218
"type": "null"
219219
}
220220
]
221+
},
222+
"ssh": {
223+
"anyOf": [
224+
{
225+
"$ref": "#/definitions/CapabilitySshServerV1"
226+
},
227+
{
228+
"type": "null"
229+
}
230+
]
221231
}
222232
},
223233
"additionalProperties": true
@@ -302,6 +312,29 @@
302312
}
303313
}
304314
},
315+
"CapabilitySshServerV1": {
316+
"description": "Configure SSH server credentials and settings.",
317+
"type": "object",
318+
"properties": {
319+
"enabled": {
320+
"description": "Enable an SSH server.",
321+
"type": [
322+
"boolean",
323+
"null"
324+
]
325+
},
326+
"users": {
327+
"type": [
328+
"array",
329+
"null"
330+
],
331+
"items": {
332+
"$ref": "#/definitions/SshUserV1"
333+
}
334+
}
335+
},
336+
"additionalProperties": true
337+
},
305338
"ExecutableJob": {
306339
"type": "object",
307340
"properties": {
@@ -731,6 +764,48 @@
731764
"PackageSource": {
732765
"type": "string"
733766
},
767+
"PasswordV1": {
768+
"oneOf": [
769+
{
770+
"description": "Plain text password.",
771+
"type": "object",
772+
"required": [
773+
"password",
774+
"type"
775+
],
776+
"properties": {
777+
"password": {
778+
"type": "string"
779+
},
780+
"type": {
781+
"type": "string",
782+
"enum": [
783+
"plain"
784+
]
785+
}
786+
}
787+
},
788+
{
789+
"description": "Bcrypt password hash.",
790+
"type": "object",
791+
"required": [
792+
"hash",
793+
"type"
794+
],
795+
"properties": {
796+
"hash": {
797+
"type": "string"
798+
},
799+
"type": {
800+
"type": "string",
801+
"enum": [
802+
"bcrypt"
803+
]
804+
}
805+
}
806+
}
807+
]
808+
},
734809
"PrettyDuration": {
735810
"type": "string"
736811
},
@@ -749,6 +824,39 @@
749824
},
750825
"SnapshotTrigger": {
751826
"type": "string"
827+
},
828+
"SshUserV1": {
829+
"type": "object",
830+
"required": [
831+
"username"
832+
],
833+
"properties": {
834+
"authorized_keys": {
835+
"description": "SSH public keys for this user.",
836+
"type": [
837+
"array",
838+
"null"
839+
],
840+
"items": {
841+
"type": "string"
842+
}
843+
},
844+
"passwords": {
845+
"description": "Passwords for this user.",
846+
"type": [
847+
"array",
848+
"null"
849+
],
850+
"items": {
851+
"$ref": "#/definitions/PasswordV1"
852+
}
853+
},
854+
"username": {
855+
"description": "The username used for SSH login.",
856+
"type": "string"
857+
}
858+
},
859+
"additionalProperties": true
752860
}
753861
}
754862
}

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)