Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add disable sys auth #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Loading