mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
Remove async references (#724)
This commit is contained in:
parent
8dc0199380
commit
53f3260285
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -638,6 +638,8 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "concread"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65099306f247b9a7bdd2919bba79355f646e477bc59ff4e8c13a1af976ed86fc"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"crossbeam",
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -2,12 +2,12 @@ use crate::session::read_tokens;
|
|||
use crate::CommonOpt;
|
||||
use compact_jwt::{Jws, JwsUnverified};
|
||||
use dialoguer::{theme::ColorfulTheme, Select};
|
||||
use kanidm_client::{KanidmAsyncClient, KanidmClientBuilder};
|
||||
use kanidm_client::{KanidmClient, KanidmClientBuilder};
|
||||
use kanidm_proto::v1::UserAuthToken;
|
||||
use std::str::FromStr;
|
||||
|
||||
impl CommonOpt {
|
||||
pub fn to_unauth_client(&self) -> KanidmAsyncClient {
|
||||
pub fn to_unauth_client(&self) -> KanidmClient {
|
||||
let config_path: String = shellexpand::tilde("~/.config/kanidm").into_owned();
|
||||
|
||||
let client_builder = KanidmClientBuilder::new()
|
||||
|
@ -46,13 +46,13 @@ impl CommonOpt {
|
|||
client_builder
|
||||
);
|
||||
|
||||
client_builder.build_async().unwrap_or_else(|e| {
|
||||
client_builder.build().unwrap_or_else(|e| {
|
||||
error!("Failed to build client instance -- {:?}", e);
|
||||
std::process::exit(1);
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn to_client(&self) -> KanidmAsyncClient {
|
||||
pub async fn to_client(&self) -> KanidmClient {
|
||||
let client = self.to_unauth_client();
|
||||
// Read the token file.
|
||||
let tokens = match read_tokens() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::common::prompt_for_username_get_username;
|
||||
use crate::{LoginOpt, LogoutOpt, SessionOpt};
|
||||
|
||||
use kanidm_client::{ClientError, KanidmAsyncClient};
|
||||
use kanidm_client::{ClientError, KanidmClient};
|
||||
use kanidm_proto::v1::{AuthAllowed, AuthResponse, AuthState, UserAuthToken};
|
||||
#[cfg(target_family = "unix")]
|
||||
use libc::umask;
|
||||
|
@ -142,10 +142,7 @@ impl LoginOpt {
|
|||
self.copt.debug
|
||||
}
|
||||
|
||||
async fn do_password(
|
||||
&self,
|
||||
client: &mut KanidmAsyncClient,
|
||||
) -> Result<AuthResponse, ClientError> {
|
||||
async fn do_password(&self, client: &mut KanidmClient) -> Result<AuthResponse, ClientError> {
|
||||
let password = rpassword::prompt_password("Enter password: ").unwrap_or_else(|e| {
|
||||
error!("Failed to create password prompt -- {:?}", e);
|
||||
std::process::exit(1);
|
||||
|
@ -153,10 +150,7 @@ impl LoginOpt {
|
|||
client.auth_step_password(password.as_str()).await
|
||||
}
|
||||
|
||||
async fn do_backup_code(
|
||||
&self,
|
||||
client: &mut KanidmAsyncClient,
|
||||
) -> Result<AuthResponse, ClientError> {
|
||||
async fn do_backup_code(&self, client: &mut KanidmClient) -> Result<AuthResponse, ClientError> {
|
||||
print!("Enter Backup Code: ");
|
||||
// We flush stdout so it'll write the buffer to screen, continuing operation. Without it, the application halts.
|
||||
#[allow(clippy::unwrap_used)]
|
||||
|
@ -174,7 +168,7 @@ impl LoginOpt {
|
|||
client.auth_step_backup_code(backup_code.trim()).await
|
||||
}
|
||||
|
||||
async fn do_totp(&self, client: &mut KanidmAsyncClient) -> Result<AuthResponse, ClientError> {
|
||||
async fn do_totp(&self, client: &mut KanidmClient) -> Result<AuthResponse, ClientError> {
|
||||
let totp = loop {
|
||||
print!("Enter TOTP: ");
|
||||
// We flush stdout so it'll write the buffer to screen, continuing operation. Without it, the application halts.
|
||||
|
@ -198,7 +192,7 @@ impl LoginOpt {
|
|||
|
||||
async fn do_webauthn(
|
||||
&self,
|
||||
client: &mut KanidmAsyncClient,
|
||||
client: &mut KanidmClient,
|
||||
pkr: RequestChallengeResponse,
|
||||
) -> Result<AuthResponse, ClientError> {
|
||||
let mut wa = WebauthnAuthenticator::new(U2FHid::new());
|
||||
|
|
|
@ -58,7 +58,7 @@ async fn main() {
|
|||
None => client_builder,
|
||||
};
|
||||
|
||||
let client = client_builder.build_async().unwrap_or_else(|e| {
|
||||
let client = client_builder.build().unwrap_or_else(|e| {
|
||||
error!("Failed to build client instance -- {:?}", e);
|
||||
std::process::exit(1);
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::db::Db;
|
||||
use crate::unix_config::{HomeAttr, UidAttr};
|
||||
use crate::unix_proto::{HomeDirectoryInfo, NssGroup, NssUser};
|
||||
use kanidm_client::asynchronous::KanidmAsyncClient;
|
||||
use kanidm_client::ClientError;
|
||||
use kanidm_client::KanidmClient;
|
||||
use kanidm_proto::v1::{OperationError, UnixGroupToken, UnixUserToken};
|
||||
use lru::LruCache;
|
||||
use reqwest::StatusCode;
|
||||
|
@ -31,7 +31,7 @@ enum CacheState {
|
|||
#[derive(Debug)]
|
||||
pub struct CacheLayer {
|
||||
db: Db,
|
||||
client: RwLock<KanidmAsyncClient>,
|
||||
client: RwLock<KanidmClient>,
|
||||
state: Mutex<CacheState>,
|
||||
pam_allow_groups: BTreeSet<String>,
|
||||
timeout_seconds: u64,
|
||||
|
@ -62,7 +62,7 @@ impl CacheLayer {
|
|||
// cache timeout
|
||||
timeout_seconds: u64,
|
||||
//
|
||||
client: KanidmAsyncClient,
|
||||
client: KanidmClient,
|
||||
pam_allow_groups: Vec<String>,
|
||||
default_shell: String,
|
||||
home_prefix: String,
|
||||
|
|
|
@ -480,7 +480,7 @@ async fn main() {
|
|||
|
||||
let cb = cb.connect_timeout(cfg.conn_timeout);
|
||||
|
||||
let rsclient = match cb.build_async() {
|
||||
let rsclient = match cb.build() {
|
||||
Ok(rsc) => rsc,
|
||||
Err(_e) => {
|
||||
error!("Failed to build async client");
|
||||
|
|
|
@ -14,7 +14,7 @@ use kanidm_unix_common::constants::{
|
|||
DEFAULT_SHELL, DEFAULT_UID_ATTR_MAP,
|
||||
};
|
||||
|
||||
use kanidm_client::{KanidmAsyncClient, KanidmClientBuilder};
|
||||
use kanidm_client::{KanidmClient, KanidmClientBuilder};
|
||||
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
@ -36,16 +36,16 @@ fn is_free_port(port: u16) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
type Fixture = Box<dyn FnOnce(KanidmAsyncClient) -> Pin<Box<dyn Future<Output = ()>>>>;
|
||||
type Fixture = Box<dyn FnOnce(KanidmClient) -> Pin<Box<dyn Future<Output = ()>>>>;
|
||||
|
||||
fn fixture<T>(f: fn(KanidmAsyncClient) -> T) -> Fixture
|
||||
fn fixture<T>(f: fn(KanidmClient) -> T) -> Fixture
|
||||
where
|
||||
T: Future<Output = ()> + 'static,
|
||||
{
|
||||
Box::new(move |n| Box::pin(f(n)))
|
||||
}
|
||||
|
||||
async fn setup_test(fix_fn: Fixture) -> (CacheLayer, KanidmAsyncClient) {
|
||||
async fn setup_test(fix_fn: Fixture) -> (CacheLayer, KanidmClient) {
|
||||
let _ = tracing_tree::test_init();
|
||||
|
||||
let mut counter = 0;
|
||||
|
@ -89,7 +89,7 @@ async fn setup_test(fix_fn: Fixture) -> (CacheLayer, KanidmAsyncClient) {
|
|||
let adminclient = KanidmClientBuilder::new()
|
||||
.address(addr.clone())
|
||||
.no_proxy()
|
||||
.build_async()
|
||||
.build()
|
||||
.expect("Failed to build sync client");
|
||||
|
||||
fix_fn(adminclient).await;
|
||||
|
@ -97,13 +97,13 @@ async fn setup_test(fix_fn: Fixture) -> (CacheLayer, KanidmAsyncClient) {
|
|||
let client = KanidmClientBuilder::new()
|
||||
.address(addr.clone())
|
||||
.no_proxy()
|
||||
.build_async()
|
||||
.build()
|
||||
.expect("Failed to build async admin client");
|
||||
|
||||
let rsclient = KanidmClientBuilder::new()
|
||||
.address(addr)
|
||||
.no_proxy()
|
||||
.build_async()
|
||||
.build()
|
||||
.expect("Failed to build client");
|
||||
|
||||
let cachelayer = CacheLayer::new(
|
||||
|
@ -127,7 +127,7 @@ async fn setup_test(fix_fn: Fixture) -> (CacheLayer, KanidmAsyncClient) {
|
|||
// let the tables hit the floor
|
||||
}
|
||||
|
||||
async fn test_fixture(rsclient: KanidmAsyncClient) {
|
||||
async fn test_fixture(rsclient: KanidmClient) {
|
||||
let res = rsclient
|
||||
.auth_simple_password("admin", ADMIN_TEST_PASSWORD)
|
||||
.await;
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::atomic::{AtomicU16, Ordering};
|
|||
use kanidm::audit::LogLevel;
|
||||
use kanidm::config::{Configuration, IntegrationTestConfig, ServerRole};
|
||||
use kanidm::tracing_tree;
|
||||
use kanidm_client::{asynchronous::KanidmAsyncClient, KanidmClientBuilder};
|
||||
use kanidm_client::{KanidmClient, KanidmClientBuilder};
|
||||
use score::create_server_core;
|
||||
use tokio::task;
|
||||
|
||||
|
@ -21,7 +21,7 @@ fn is_free_port(port: u16) -> bool {
|
|||
}
|
||||
|
||||
// Test external behaviours of the service.
|
||||
pub async fn setup_async_test() -> KanidmAsyncClient {
|
||||
pub async fn setup_async_test() -> KanidmClient {
|
||||
let _ = tracing_tree::test_init();
|
||||
|
||||
let mut counter = 0;
|
||||
|
@ -63,7 +63,7 @@ pub async fn setup_async_test() -> KanidmAsyncClient {
|
|||
let rsclient = KanidmClientBuilder::new()
|
||||
.address(addr)
|
||||
.no_proxy()
|
||||
.build_async()
|
||||
.build()
|
||||
.expect("Failed to build client");
|
||||
|
||||
rsclient
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#![deny(warnings)]
|
||||
use std::collections::HashSet;
|
||||
|
||||
use kanidm_client::asynchronous::KanidmAsyncClient;
|
||||
use kanidm_client::KanidmClient;
|
||||
use kanidm_proto::v1::{Filter, Modify, ModifyList};
|
||||
|
||||
mod common;
|
||||
|
@ -56,7 +56,7 @@ static DEFAULT_HP_GROUP_NAMES: [&str; 24] = [
|
|||
static DEFAULT_NOT_HP_GROUP_NAMES: [&str; 2] =
|
||||
["idm_account_unix_extend_priv", "idm_group_unix_extend_priv"];
|
||||
|
||||
async fn create_user(rsclient: &KanidmAsyncClient, id: &str, group_name: &str) -> () {
|
||||
async fn create_user(rsclient: &KanidmClient, id: &str, group_name: &str) -> () {
|
||||
rsclient.idm_account_create(id, id).await.unwrap();
|
||||
|
||||
// Create group and add to user to test read attr: member_of
|
||||
|
@ -70,7 +70,7 @@ async fn create_user(rsclient: &KanidmAsyncClient, id: &str, group_name: &str) -
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
async fn is_attr_writable(rsclient: &KanidmAsyncClient, id: &str, attr: &str) -> Option<bool> {
|
||||
async fn is_attr_writable(rsclient: &KanidmClient, id: &str, attr: &str) -> Option<bool> {
|
||||
println!("writing to attribute: {}", attr);
|
||||
match attr {
|
||||
"radius_secret" => Some(
|
||||
|
@ -130,7 +130,7 @@ async fn is_attr_writable(rsclient: &KanidmAsyncClient, id: &str, attr: &str) ->
|
|||
}
|
||||
}
|
||||
|
||||
async fn add_all_attrs(rsclient: &KanidmAsyncClient, id: &str, group_name: &str) {
|
||||
async fn add_all_attrs(rsclient: &KanidmClient, id: &str, group_name: &str) {
|
||||
// Extend with posix attrs to test read attr: gidnumber and loginshell
|
||||
rsclient
|
||||
.idm_group_add_members("idm_admins", &[ADMIN_TEST_USER])
|
||||
|
@ -170,7 +170,7 @@ async fn add_all_attrs(rsclient: &KanidmAsyncClient, id: &str, group_name: &str)
|
|||
}
|
||||
|
||||
async fn create_user_with_all_attrs(
|
||||
rsclient: &KanidmAsyncClient,
|
||||
rsclient: &KanidmClient,
|
||||
id: &str,
|
||||
optional_group: Option<&str>,
|
||||
) -> () {
|
||||
|
@ -181,7 +181,7 @@ async fn create_user_with_all_attrs(
|
|||
add_all_attrs(&rsclient, id, group_name).await;
|
||||
}
|
||||
|
||||
async fn login_account(rsclient: &KanidmAsyncClient, id: &str) -> () {
|
||||
async fn login_account(rsclient: &KanidmClient, id: &str) -> () {
|
||||
rsclient
|
||||
.idm_group_add_members(
|
||||
"idm_people_account_password_import_priv",
|
||||
|
@ -210,7 +210,7 @@ async fn login_account(rsclient: &KanidmAsyncClient, id: &str) -> () {
|
|||
// Login to the given account, but first login with default admin credentials.
|
||||
// This is necessary when switching between unprivileged accounts, but adds extra calls which
|
||||
// create extra debugging noise, so should be avoided when unnecessary.
|
||||
async fn login_account_via_admin(rsclient: &KanidmAsyncClient, id: &str) -> () {
|
||||
async fn login_account_via_admin(rsclient: &KanidmClient, id: &str) -> () {
|
||||
let _ = rsclient.logout();
|
||||
rsclient
|
||||
.auth_simple_password(ADMIN_TEST_USER, ADMIN_TEST_PASSWORD)
|
||||
|
@ -220,7 +220,7 @@ async fn login_account_via_admin(rsclient: &KanidmAsyncClient, id: &str) -> () {
|
|||
}
|
||||
|
||||
async fn test_read_attrs(
|
||||
rsclient: &KanidmAsyncClient,
|
||||
rsclient: &KanidmClient,
|
||||
id: &str,
|
||||
attrs: &[&str],
|
||||
is_readable: bool,
|
||||
|
@ -247,7 +247,7 @@ async fn test_read_attrs(
|
|||
}
|
||||
|
||||
async fn test_write_attrs(
|
||||
rsclient: &KanidmAsyncClient,
|
||||
rsclient: &KanidmClient,
|
||||
id: &str,
|
||||
attrs: &[&str],
|
||||
is_writeable: bool,
|
||||
|
@ -261,7 +261,7 @@ async fn test_write_attrs(
|
|||
}
|
||||
|
||||
async fn test_modify_group(
|
||||
rsclient: &KanidmAsyncClient,
|
||||
rsclient: &KanidmClient,
|
||||
group_names: &[&str],
|
||||
is_modificable: bool,
|
||||
) -> () {
|
||||
|
|
|
@ -2,9 +2,7 @@ use crate::data::*;
|
|||
use crate::ldap::{LdapClient, LdapSchema};
|
||||
use crate::profile::{KaniHttpConfig, KaniLdapConfig};
|
||||
use crate::{TargetServer, TargetServerBuilder};
|
||||
use kanidm_client::{
|
||||
asynchronous::KanidmAsyncClient, ClientError, KanidmClientBuilder, StatusCode,
|
||||
};
|
||||
use kanidm_client::{ClientError, KanidmClient, KanidmClientBuilder, StatusCode};
|
||||
use kanidm_proto::v1::*;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::time::{Duration, Instant};
|
||||
|
@ -14,7 +12,7 @@ use uuid::Uuid;
|
|||
pub struct KaniHttpServer {
|
||||
uri: String,
|
||||
admin_pw: String,
|
||||
client: KanidmAsyncClient,
|
||||
client: KanidmClient,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -29,7 +27,7 @@ impl KaniHttpServer {
|
|||
.address(uri.clone())
|
||||
.danger_accept_invalid_hostnames(true)
|
||||
.danger_accept_invalid_certs(true)
|
||||
.build_async()
|
||||
.build()
|
||||
.map_err(|e| {
|
||||
error!("Unable to create kanidm client {:?}", e);
|
||||
})?;
|
||||
|
|
Loading…
Reference in a new issue