+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/api/sys/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ pub struct EnableAuthRequest {
pub config: Option<EnableAuthDataConfig>,
}

/// ## 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: <https://developer.hashicorp.com/vault/api-docs/system/auth#disable-auth-method>

#[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 {
Expand Down
13 changes: 12 additions & 1 deletion src/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions vaultrs-tests/tests/api_tests/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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;
Expand Down Expand Up @@ -134,6 +135,10 @@ mod auth {
pub async fn test_list_auth(client: &impl Client) {
auth::list(client).await.unwrap();
}

pub async fn test_disable_auth(client: &impl Client) {
auth::disable(client, "oidc_temp").await.unwrap();
}
}

mod policy {
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载