Watch
0
0
Fork
You've already forked hyperhive
0

disable a destroyed agent's identity entity and delete its login role

This commit is contained in:
atlas 2026-11-16 16:50:53 +01:00
commit 299b922039

View file

@ -607,6 +607,46 @@ impl SecretStore {
Ok(())
}
/// Set the `disabled` flag of the identity entity `name` and nothing else
/// about it.
///
/// A disabled entity's tokens are refused by the store at once, the ones
/// already issued included, and a new login that lands on it is refused too.
/// The write names only the flag, so the entity's name and aliases stay and
/// [`create_entity`][Self::create_entity] never clears it.
///
/// The store creates the entity when none has that name: callers look it up
/// first when they do not want one made.
///
/// # Errors
/// [`Error::Vault`] when the token's policy does not cover
/// `identity/entity/name/<name>` with the `disabled` key.
pub async fn set_entity_disabled(&self, name: &str, disabled: bool) -> Result<(), Error> {
let request = SetEntityDisabled {
name: name.to_owned(),
disabled,
};
vaultrs::api::exec_with_empty(&self.inner, request).await?;
Ok(())
}
/// Delete the cert-auth role `name`, so a certificate that logged in under
/// it cannot log in again.
///
/// **Idempotent.** A role that is not there is deleted already; only a 404 is
/// absence, as in [`delete_all_versions`][Self::delete_all_versions].
///
/// # Errors
/// [`Error::Vault`] when the token's policy does not cover
/// `auth/<mount>/certs/<name>`, or the store is unreachable.
pub async fn delete_cert_role(&self, mount: &str, name: &str) -> Result<(), Error> {
match vaultrs::auth::cert::ca_cert_role::delete(&self.inner, mount, name).await {
Ok(()) => Ok(()),
Err(e) if is_absent(&e) => Ok(()),
Err(e) => Err(e.into()),
}
}
/// Attach the alias `alias_name` on the auth mount `mount_accessor` to
/// the entity `entity_id`, so that a login under that name lands on it.
///
@ -691,6 +731,16 @@ struct CreateEntityByName {
name: String,
}
/// Only `disabled` is sent, which is the one key beside `name` the controller's
/// grant on this path allows.
#[derive(Endpoint)]
#[endpoint(path = "identity/entity/name/{self.name}", method = "POST")]
struct SetEntityDisabled {
#[endpoint(skip)]
name: String,
disabled: bool,
}
#[derive(Endpoint)]
#[endpoint(path = "identity/entity/id/{self.id}", method = "POST")]
struct RenameEntity {
@ -1220,6 +1270,13 @@ mod tests {
assert_eq!(create.path(), "identity/entity/name/atlas");
assert!(keys(create.body().expect("body")).is_empty());
let disable = SetEntityDisabled {
name: "atlas".to_owned(),
disabled: true,
};
assert_eq!(disable.path(), "identity/entity/name/atlas");
assert_eq!(keys(disable.body().expect("body")), ["disabled"]);
let rename = RenameEntity {
id: "e1".to_owned(),
name: "atlas".to_owned(),