mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 04:27:02 +01:00
parent
9c2825b9dc
commit
4938c6796b
|
@ -1,5 +1,5 @@
|
|||
use crate::common::OpType;
|
||||
use crate::{handle_client_error, GroupAccountPolicyOpt};
|
||||
use crate::{handle_client_error, handle_group_account_policy_error, GroupAccountPolicyOpt};
|
||||
|
||||
impl GroupAccountPolicyOpt {
|
||||
pub fn debug(&self) -> bool {
|
||||
|
@ -38,7 +38,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_authsession_expiry_set(name, *expiry)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Updated authsession expiry.");
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_authsession_expiry_reset(name)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Successfully reset authsession expiry.");
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_credential_type_minimum_set(name, value.as_str())
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Updated credential type minimum.");
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_password_minimum_length_set(name, *length)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Updated password minimum length.");
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_password_minimum_length_reset(name)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Successfully reset password minimum length.");
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_privilege_expiry_set(name, *expiry)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Updated privilege session expiry.");
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_privilege_expiry_reset(name)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Successfully reset privilege session expiry.");
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_webauthn_attestation_set(name, &json)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Updated webauthn attestation CA list.");
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_webauthn_attestation_reset(name)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Successfully reset webauthn attestation CA list.");
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_limit_search_max_results(name, *maximum)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Updated search maximum results limit.");
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_limit_search_max_results_reset(name)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Successfully reset search maximum results limit to default.");
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_limit_search_max_filter_test(name, *maximum)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Updated search maximum filter test limit.");
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_limit_search_max_filter_test_reset(name)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Successfully reset search maximum filter test limit.");
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ impl GroupAccountPolicyOpt {
|
|||
.group_account_policy_allow_primary_cred_fallback(name, *allow)
|
||||
.await
|
||||
{
|
||||
handle_client_error(e, copt.output_mode);
|
||||
handle_group_account_policy_error(e, copt.output_mode);
|
||||
} else {
|
||||
println!("Updated primary credential fallback policy.");
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ mod webauthn;
|
|||
pub(crate) fn handle_client_error(response: ClientError, _output_mode: OutputMode) {
|
||||
match response {
|
||||
ClientError::Http(status, error, opid) => {
|
||||
let error_msg = match error {
|
||||
let error_msg = match &error {
|
||||
Some(msg) => format!(" {:?}", msg),
|
||||
None => "".to_string(),
|
||||
};
|
||||
|
@ -70,6 +70,18 @@ pub(crate) fn handle_client_error(response: ClientError, _output_mode: OutputMod
|
|||
};
|
||||
}
|
||||
|
||||
pub(crate) fn handle_group_account_policy_error(response: ClientError, _output_mode: OutputMode) {
|
||||
use kanidm_proto::internal::OperationError::SchemaViolation;
|
||||
use kanidm_proto::internal::SchemaError::AttributeNotValidForClass;
|
||||
|
||||
if let ClientError::Http(_status, Some(SchemaViolation(AttributeNotValidForClass(att))), opid) = response {
|
||||
error!("OperationId: {:?}", opid);
|
||||
error!("Cannot update account-policy attribute {att}. Is account-policy enabled on this group?");
|
||||
} else {
|
||||
handle_client_error(response, _output_mode);
|
||||
}
|
||||
}
|
||||
|
||||
impl SelfOpt {
|
||||
pub fn debug(&self) -> bool {
|
||||
match self {
|
||||
|
|
Loading…
Reference in a new issue