vaultrs/api/ssh/requests.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
use std::collections::HashMap;
use super::responses::{
GenerateSSHCredsResponse, ListRolesByIPResponse, ListRolesResponse,
ListZeroAddressRolesResponse, ReadPublicKeyResponse, ReadRoleResponse, SignSSHKeyResponse,
SubmitCAInfoResponse, VerifySSHOTPResponse,
};
use rustify_derive::Endpoint;
/// ## Create/Update Key
/// This endpoint creates or updates a named key.
///
/// * Path: {self.mount}/keys/{self.name}
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#create-update-key>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/keys/{self.name}",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct SetKeyRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
pub key: String,
}
/// ## Delete Key
/// This endpoint deletes a named key.
///
/// * Path: {self.mount}/keys/{self.name}
/// * Method: DELETE
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#delete-key>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/keys/{self.name}",
method = "DELETE",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct DeleteKeyRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## Create Role
/// This endpoint creates or updates a named role.
///
/// * Path: {self.mount}/roles/{self.name}
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#create-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/roles/{self.name}",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct SetRoleRequest {
#[endpoint(skip)]
pub mount: String,
pub name: String,
pub key_type: String,
pub algorithm_signer: Option<String>,
pub allow_bare_domains: Option<bool>,
pub allow_host_certificates: Option<bool>,
pub allow_subdomains: Option<bool>,
pub allow_user_certificates: Option<bool>,
pub allow_user_key_ids: Option<bool>,
pub allowed_user_key_lengths: Option<HashMap<String, u64>>,
pub allowed_critical_options: Option<HashMap<String, String>>,
pub allowed_domains: Option<String>,
pub allowed_extensions: Option<String>,
pub allowed_users: Option<String>,
pub allowed_users_template: Option<bool>,
pub admin_user: Option<String>,
pub cidr_list: Option<String>,
pub efault_critical_options: Option<HashMap<String, String>>,
pub default_user: Option<String>,
pub exclude_cidr_list: Option<String>,
pub install_script: Option<String>,
pub key: Option<String>,
pub key_bits: Option<u64>,
pub key_id_format: Option<String>,
pub key_option_specs: Option<String>,
pub max_ttl: Option<String>,
pub port: Option<u64>,
pub ttl: Option<String>,
}
/// ## Read Role
/// This endpoint queries a named role.
///
/// * Path: {self.mount}/roles/{self.name}
/// * Method: GET
/// * Response: [ReadRoleResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#read-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/roles/{self.name}",
response = "ReadRoleResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ReadRoleRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## List Roles
/// This endpoint returns a list of available roles.
///
/// * Path: {self.mount}/roles
/// * Method: LIST
/// * Response: [ListRolesResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#list-roles>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/roles",
method = "LIST",
response = "ListRolesResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ListRolesRequest {
#[endpoint(skip)]
pub mount: String,
}
/// ## Delete Role
/// This endpoint deletes a named role.
///
/// * Path: {self.mount}/roles/{self.name}
/// * Method: DELETE
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#delete-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/roles/{self.name}",
method = "DELETE",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct DeleteRoleRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
}
/// ## List Zero-Address Roles
/// This endpoint returns the list of configured zero-address roles.
///
/// * Path: {self.mount}/config/zeroaddress
/// * Method: GET
/// * Response: [ListZeroAddressRolesResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#list-zero-address-roles>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/config/zeroaddress",
response = "ListZeroAddressRolesResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ListZeroAddressRolesRequest {
#[endpoint(skip)]
pub mount: String,
}
/// ## Configure Zero-Address Roles
/// This endpoint configures zero-address roles.
///
/// * Path: {self.mount}/config/zeroaddress
/// * Method: POST
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#configure-zero-address-roles>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/config/zeroaddress",
method = "POST",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ConfigureZeroAddressRolesRequest {
#[endpoint(skip)]
pub mount: String,
pub roles: Vec<String>,
}
/// ## Delete Zero-Address Role
/// This endpoint deletes the zero-address roles configuration.
///
/// * Path: {self.mount}/roles/{self.name}
/// * Method: DELETE
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#delete-zero-address-role>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/roles/zeroaddress",
method = "DELETE",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct DeleteZeroAddressRolesRequest {
#[endpoint(skip)]
pub mount: String,
}
/// ## Generate SSH Credentials
/// This endpoint creates credentials for a specific username and IP with the
/// parameters defined in the given role.
///
/// * Path: {self.mount}/creds/{self.name}
/// * Method: POST
/// * Response: [GenerateSSHCredsResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#generate-ssh-credentials>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/creds/{self.name}",
method = "POST",
response = "GenerateSSHCredsResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct GenerateSSHCredsRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
pub ip: String,
pub username: Option<String>,
}
/// ## List Roles by IP
/// This endpoint lists all of the roles with which the given IP is associated.
///
/// * Path: {self.mount}/lookup
/// * Method: POST
/// * Response: [ListRolesByIPResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#list-roles-by-ip>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/lookup",
method = "POST",
response = "ListRolesByIPResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ListRolesByIPRequest {
#[endpoint(skip)]
pub mount: String,
pub ip: String,
}
/// ## Verify SSH OTP
/// This endpoint verifies if the given OTP is valid.
///
/// * Path: {self.mount}/verify
/// * Method: POST
/// * Response: [VerifySSHOTPResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#verify-ssh-otp>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/verify",
method = "POST",
response = "VerifySSHOTPResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct VerifySSHOTPRequest {
#[endpoint(skip)]
pub mount: String,
pub otp: String,
}
/// ## Submit CA Information
/// This endpoint allows submitting the CA information for the secrets engine
/// via an SSH key pair.
///
/// * Path: {self.mount}/config/ca
/// * Method: POST
/// * Response: [SubmitCAInfoResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#submit-ca-information>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/config/ca",
method = "POST",
response = "SubmitCAInfoResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct SubmitCAInfoRequest {
#[endpoint(skip)]
pub mount: String,
pub generate_signing_key: Option<bool>,
pub private_key: Option<String>,
pub public_key: Option<String>,
}
/// ## Delete CA Information
/// This endpoint deletes the CA information for the backend via an SSH key pair.
///
/// * Path: {self.mount}/config/ca
/// * Method: DELETE
/// * Response: N/A
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#delete-ca-information>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(path = "{self.mount}/config/ca", method = "DELETE", builder = "true")]
#[builder(setter(into, strip_option), default)]
pub struct DeleteCAInfoRequest {
#[endpoint(skip)]
pub mount: String,
}
/// ## Read Public Key
/// This endpoint reads the configured/generated public key.
///
/// * Path: {self.mount}/config/ca
/// * Method: GET
/// * Response: [ReadPublicKeyResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#read-public-key-authenticated>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/config/ca",
response = "ReadPublicKeyResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct ReadPublicKeyRequest {
#[endpoint(skip)]
pub mount: String,
}
/// ## Sign SSH Key
/// This endpoint signs an SSH public key based on the supplied parameters,
/// subject to the restrictions contained in the role named in the endpoint.
///
/// * Path: {self.mount}/sign/{self.name}
/// * Method: POST
/// * Response: [SignSSHKeyResponse]
/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/ssh#sign-ssh-key>
#[derive(Builder, Debug, Default, Endpoint)]
#[endpoint(
path = "{self.mount}/sign/{self.name}",
method = "POST",
response = "SignSSHKeyResponse",
builder = "true"
)]
#[builder(setter(into, strip_option), default)]
pub struct SignSSHKeyRequest {
#[endpoint(skip)]
pub mount: String,
#[endpoint(skip)]
pub name: String,
pub cert_type: Option<String>,
pub critical_options: Option<HashMap<String, String>>,
pub extensions: Option<HashMap<String, String>>,
pub key_id: Option<String>,
pub public_key: String,
pub ttl: Option<String>,
pub valid_principals: Option<String>,
}