Authorize remote modules with bearer proofs
This commit is contained in:
parent
72cd018a3e
commit
7e39a19c18
8 changed files with 572 additions and 120 deletions
|
|
@ -251,6 +251,8 @@ pub enum CasCommand {
|
|||
Fetch {
|
||||
node: String,
|
||||
hash: String,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
Hash {
|
||||
path: PathBuf,
|
||||
|
|
@ -335,6 +337,8 @@ pub enum KvCommand {
|
|||
Sync {
|
||||
node: String,
|
||||
name: String,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -345,11 +349,15 @@ pub enum PubsubCommand {
|
|||
message: String,
|
||||
#[arg(long)]
|
||||
node: Option<String>,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
Sub {
|
||||
topic: String,
|
||||
#[arg(long)]
|
||||
node: Option<String>,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -362,6 +370,8 @@ pub enum PipeCommand {
|
|||
target: String,
|
||||
#[arg(long)]
|
||||
node: Option<String>,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -386,22 +396,40 @@ pub enum DbCommand {
|
|||
name: String,
|
||||
#[arg(long, default_value_t = 100)]
|
||||
limit: u32,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum DocumentCommand {
|
||||
Create { name: String },
|
||||
Status { name: String },
|
||||
Set { name: String, state_json: String },
|
||||
Get { name: String },
|
||||
Sync { node: String, name: String },
|
||||
Create {
|
||||
name: String,
|
||||
},
|
||||
Status {
|
||||
name: String,
|
||||
},
|
||||
Set {
|
||||
name: String,
|
||||
state_json: String,
|
||||
},
|
||||
Get {
|
||||
name: String,
|
||||
},
|
||||
Sync {
|
||||
node: String,
|
||||
name: String,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum SshCommand {
|
||||
Proxy {
|
||||
node: String,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
Cert {
|
||||
#[command(subcommand)]
|
||||
|
|
@ -463,6 +491,8 @@ pub enum SshCertCommand {
|
|||
},
|
||||
Sync {
|
||||
node: String,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -499,6 +529,8 @@ pub enum SshRevocationCommand {
|
|||
},
|
||||
Sync {
|
||||
node: String,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -671,9 +703,14 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
hash: hash.into(),
|
||||
out,
|
||||
},
|
||||
CasCommand::Fetch { node, hash } => ControlRequest::CasFetch {
|
||||
CasCommand::Fetch {
|
||||
node,
|
||||
hash,
|
||||
bearer_secret,
|
||||
} => ControlRequest::CasFetch {
|
||||
node,
|
||||
hash: hash.into(),
|
||||
bearer_secret,
|
||||
},
|
||||
CasCommand::Hash { path } => ControlRequest::CasHash { path },
|
||||
CasCommand::Has { hash } => ControlRequest::CasHas { hash: hash.into() },
|
||||
|
|
@ -731,23 +768,49 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
subject,
|
||||
},
|
||||
KvCommand::Get { name, key } => ControlRequest::KvGet { name, key },
|
||||
KvCommand::Sync { node, name } => ControlRequest::KvSync { node, name },
|
||||
KvCommand::Sync {
|
||||
node,
|
||||
name,
|
||||
bearer_secret,
|
||||
} => ControlRequest::KvSync {
|
||||
node,
|
||||
name,
|
||||
bearer_secret,
|
||||
},
|
||||
},
|
||||
Command::Pubsub { command } => match command {
|
||||
PubsubCommand::Pub {
|
||||
topic,
|
||||
message,
|
||||
node,
|
||||
bearer_secret,
|
||||
} => ControlRequest::PubsubPub {
|
||||
topic,
|
||||
message,
|
||||
node,
|
||||
bearer_secret,
|
||||
},
|
||||
PubsubCommand::Sub {
|
||||
topic,
|
||||
node,
|
||||
bearer_secret,
|
||||
} => ControlRequest::PubsubSub {
|
||||
topic,
|
||||
node,
|
||||
bearer_secret,
|
||||
},
|
||||
PubsubCommand::Sub { topic, node } => ControlRequest::PubsubSub { topic, node },
|
||||
},
|
||||
Command::Pipe { command } => match command {
|
||||
PipeCommand::Listen { name } => ControlRequest::PipeListen { name },
|
||||
PipeCommand::Connect { target, node } => ControlRequest::PipeConnect { target, node },
|
||||
PipeCommand::Connect {
|
||||
target,
|
||||
node,
|
||||
bearer_secret,
|
||||
} => ControlRequest::PipeConnect {
|
||||
target,
|
||||
node,
|
||||
bearer_secret,
|
||||
},
|
||||
},
|
||||
Command::Db { command } => match command {
|
||||
DbCommand::Add { name, path } => ControlRequest::DbAdd { name, path },
|
||||
|
|
@ -761,7 +824,17 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
after_db_version,
|
||||
limit,
|
||||
},
|
||||
DbCommand::Sync { node, name, limit } => ControlRequest::DbSync { node, name, limit },
|
||||
DbCommand::Sync {
|
||||
node,
|
||||
name,
|
||||
limit,
|
||||
bearer_secret,
|
||||
} => ControlRequest::DbSync {
|
||||
node,
|
||||
name,
|
||||
limit,
|
||||
bearer_secret,
|
||||
},
|
||||
},
|
||||
Command::Document { command } => match command {
|
||||
DocumentCommand::Create { name } => ControlRequest::DocumentCreate { name },
|
||||
|
|
@ -770,10 +843,24 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
ControlRequest::DocumentSet { name, state_json }
|
||||
}
|
||||
DocumentCommand::Get { name } => ControlRequest::DocumentGet { name },
|
||||
DocumentCommand::Sync { node, name } => ControlRequest::DocumentSync { node, name },
|
||||
DocumentCommand::Sync {
|
||||
node,
|
||||
name,
|
||||
bearer_secret,
|
||||
} => ControlRequest::DocumentSync {
|
||||
node,
|
||||
name,
|
||||
bearer_secret,
|
||||
},
|
||||
},
|
||||
Command::Ssh { command } => match command {
|
||||
SshCommand::Proxy { node } => ControlRequest::SshProxyConnect { node },
|
||||
SshCommand::Proxy {
|
||||
node,
|
||||
bearer_secret,
|
||||
} => ControlRequest::SshProxyConnect {
|
||||
node,
|
||||
bearer_secret,
|
||||
},
|
||||
SshCommand::Cert { command } => match command {
|
||||
SshCertCommand::Request {
|
||||
public_key,
|
||||
|
|
@ -820,7 +907,13 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
subject,
|
||||
},
|
||||
SshCertCommand::List { subject } => ControlRequest::SshCertList { subject },
|
||||
SshCertCommand::Sync { node } => ControlRequest::SshCertSync { node },
|
||||
SshCertCommand::Sync {
|
||||
node,
|
||||
bearer_secret,
|
||||
} => ControlRequest::SshCertSync {
|
||||
node,
|
||||
bearer_secret,
|
||||
},
|
||||
},
|
||||
SshCommand::Revocation { command } => match command {
|
||||
SshRevocationCommand::Add {
|
||||
|
|
@ -857,7 +950,13 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
format,
|
||||
subject,
|
||||
},
|
||||
SshRevocationCommand::Sync { node } => ControlRequest::SshRevocationSync { node },
|
||||
SshRevocationCommand::Sync {
|
||||
node,
|
||||
bearer_secret,
|
||||
} => ControlRequest::SshRevocationSync {
|
||||
node,
|
||||
bearer_secret,
|
||||
},
|
||||
},
|
||||
},
|
||||
Command::Init | Command::Daemon { .. } => bail!("command is handled directly"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue