diff --git a/src/api/sys/requests.rs b/src/api/sys/requests.rs index 2a618ff..5a00b39 100644 --- a/src/api/sys/requests.rs +++ b/src/api/sys/requests.rs @@ -116,6 +116,22 @@ pub struct EnableAuthRequest { pub config: Option, } +/// ## Disable Auth Method +/// This endpoint disables the auth method at the given auth path. +/// +/// * Path: sys/auth/{self.path} +/// * Method: DELETE +/// * Response: N/A +/// * Reference: + +#[derive(Builder, Debug, Default, Endpoint, Serialize)] +#[endpoint(path = "sys/auth/{self.path}", method = "DELETE", builder = "true")] +#[builder(setter(into, strip_option), default)] +pub struct DisableAuthRequest { + #[endpoint(skip)] + pub path: String, +} + #[derive(Clone, Builder, Debug, Default, Serialize)] #[builder(setter(into, strip_option), default)] pub struct EnableAuthDataConfig { diff --git a/src/sys.rs b/src/sys.rs index 57c4d2a..c390d4e 100644 --- a/src/sys.rs +++ b/src/sys.rs @@ -119,7 +119,7 @@ pub mod auth { use crate::api; use crate::api::sys::requests::{ - EnableAuthRequest, EnableAuthRequestBuilder, ListAuthsRequest, + DisableAuthRequest, EnableAuthRequest, EnableAuthRequestBuilder, ListAuthsRequest, }; use crate::api::sys::responses::AuthResponse; use crate::client::Client; @@ -144,6 +144,17 @@ pub mod auth { api::exec_with_empty(client, endpoint).await } + /// Disables the auth method at the given auth path. + /// + /// `sudo` required - This endpoint requires `sudo` capability in + /// addition to any path-specific capabilities. + /// + /// See [DisableAuthRequest] + pub async fn disable(client: &impl Client, path: &str) -> Result<(), ClientError> { + let endpoint = DisableAuthRequest::builder().path(path).build().unwrap(); + api::exec_with_empty(client, endpoint).await + } + /// Lists all mounted auth engines /// /// See [ListAuthsRequest] diff --git a/vaultrs-tests/tests/api_tests/sys.rs b/vaultrs-tests/tests/api_tests/sys.rs index 083c689..4dd1537 100644 --- a/vaultrs-tests/tests/api_tests/sys.rs +++ b/vaultrs-tests/tests/api_tests/sys.rs @@ -38,6 +38,7 @@ async fn test() { // Test auth auth::test_create_auth(client).await; auth::test_list_auth(client).await; + auth::test_disable_auth(client).await; // Test policy policy::test_set_policy(client).await; @@ -148,6 +149,10 @@ mod auth { let resp = auth::list(client).await; assert!(resp.is_ok()); } + + pub async fn test_disable_auth(client: &impl Client) { + auth::disable(client, "oidc_temp").await.unwrap(); + } } mod policy {