Skip to content

Commit

Permalink
Merge pull request #406 from stakwork/change-swarm-password-from-supe…
Browse files Browse the repository at this point in the history
…radmin

Change swarm password from superadmin
  • Loading branch information
Evanfeenstra authored Nov 20, 2024
2 parents 5ec0a37 + 138bdef commit 8eb0c1e
Show file tree
Hide file tree
Showing 11 changed files with 446 additions and 303 deletions.
3 changes: 2 additions & 1 deletion app/src/api/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export type Cmd =
| "UpdateAwsInstanceType"
| "GetInstanceType"
| "GetAllImageActualVersion"
| "GetSwarmChildImageVersions";
| "GetSwarmChildImageVersions"
| "ChangeChildSwarmPassword";

interface CmdData {
cmd: Cmd;
Expand Down
19 changes: 19 additions & 0 deletions app/src/api/swarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,25 @@ export async function restart_child_swarm_containers({
return await swarmCmd("RestartChildSwarmContainers", { nodes, host });
}

export async function change_child_swarm_password({
old_password,
new_password,
host,
username,
}: {
old_password: string;
new_password: string;
host: string;
username?: string;
}) {
return await swarmCmd("ChangeChildSwarmPassword", {
old_password,
new_password,
host,
username: username || "admin",
});
}

export async function start_child_swarm_containers({
nodes,
host,
Expand Down
2 changes: 0 additions & 2 deletions src/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use crate::utils::{domain, getenv};
use anyhow::{Context, Result};
use aws_config::meta::region::RegionProviderChain;
use aws_config::Region;
use aws_sdk_ec2::error::{ProvideErrorMetadata, SdkError};
use aws_sdk_s3::operation::create_multipart_upload::CreateMultipartUploadOutput;
use aws_sdk_s3::types::{CompletedMultipartUpload, CompletedPart, Delete, ObjectIdentifier};
use aws_sdk_s3::Client;
use aws_smithy_types::byte_stream::{ByteStream, Length};
Expand Down
20 changes: 20 additions & 0 deletions src/bin/super/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ pub struct UpdateSwarmInfo {
pub description: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ChangeSwarmChildPasswordInfo {
pub host: String,
pub old_password: String,
pub new_password: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ChangeUserPasswordBySuperAdminRequest {
pub host: String,
pub old_password: String,
pub new_password: String,
pub username: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ChangeSwarmChildPasswordData {
pub old_pass: String,
pub password: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DeleteSwarmInfo {
pub host: String,
Expand Down Expand Up @@ -80,6 +99,7 @@ pub enum SwarmCmd {
UpdateAwsInstanceType(UpdateInstanceDetails),
GetInstanceType(GetInstanceTypeByInstanceId),
GetSwarmChildImageVersions(ChildSwarmIdentifier),
ChangeChildSwarmPassword(ChangeUserPasswordBySuperAdminRequest),
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
5 changes: 5 additions & 0 deletions src/bin/super/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use util::{
accessing_child_container_controller, add_new_swarm_details, add_new_swarm_from_child_swarm,
get_aws_instance_types, get_child_swarm_config, get_child_swarm_containers,
get_child_swarm_image_versions, get_config, get_swarm_instance_type, update_aws_instance_type,
update_swarm_child_password,
};

use crate::checker::swarm_checker;
Expand Down Expand Up @@ -396,6 +397,10 @@ pub async fn super_handle(
}
Some(serde_json::to_string(&res)?)
}
SwarmCmd::ChangeChildSwarmPassword(info) => {
let res: SuperSwarmResponse = update_swarm_child_password(info, &state).await;
Some(serde_json::to_string(&res)?)
}
},
};

Expand Down
Loading

0 comments on commit 8eb0c1e

Please sign in to comment.