mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 12:37:00 +01:00
started working on fixing a log issue and chased some clippy lints (#1182)
This commit is contained in:
parent
1ed4d7c1bd
commit
69b9c5845a
|
@ -103,8 +103,7 @@ impl PwBadlistOpt {
|
|||
|
||||
let filt_pwset: Vec<_> = results
|
||||
.into_iter()
|
||||
.map(|res| res.expect("Thread join failure"))
|
||||
.flatten()
|
||||
.flat_map(|res| res.expect("Thread join failure"))
|
||||
.collect();
|
||||
|
||||
info!(
|
||||
|
|
|
@ -16,7 +16,7 @@ pub(crate) fn qs_test(_args: &TokenStream, item: TokenStream, with_init: bool) -
|
|||
|
||||
if let Some(attr) = input.attrs.iter().find(|attr| attr.path.is_ident("test")) {
|
||||
let msg = "second test attribute is supplied";
|
||||
return token_stream_with_error(item, syn::Error::new_spanned(&attr, msg));
|
||||
return token_stream_with_error(item, syn::Error::new_spanned(attr, msg));
|
||||
};
|
||||
|
||||
if input.sig.asyncness.is_none() {
|
||||
|
@ -106,7 +106,7 @@ pub(crate) fn idm_test(_args: &TokenStream, item: TokenStream) -> TokenStream {
|
|||
|
||||
if let Some(attr) = input.attrs.iter().find(|attr| attr.path.is_ident("test")) {
|
||||
let msg = "second test attribute is supplied";
|
||||
return token_stream_with_error(item, syn::Error::new_spanned(&attr, msg));
|
||||
return token_stream_with_error(item, syn::Error::new_spanned(attr, msg));
|
||||
};
|
||||
|
||||
if input.sig.asyncness.is_none() {
|
||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
|||
if let Ok(v) = env::var("DEP_OPENSSL_VERSION_NUMBER") {
|
||||
let version = u64::from_str_radix(&v, 16).unwrap();
|
||||
|
||||
if version >= 0x3_00_00_00_0 {
|
||||
if version >= 0x3000_0000 {
|
||||
println!("cargo:rustc-cfg=openssl3");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -999,7 +999,7 @@ impl IdlSqliteWriteTransaction {
|
|||
idx_table_list.iter().try_for_each(|idx_table| {
|
||||
trace!(table = ?idx_table, "removing idx_table");
|
||||
self.conn
|
||||
.prepare(&format!("DROP TABLE {}.{}", "main", idx_table).as_str())
|
||||
.prepare(format!("DROP TABLE {}.{}", "main", idx_table).as_str())
|
||||
.and_then(|mut stmt| stmt.execute([]).map(|_| ()))
|
||||
.map_err(sqlite_error)
|
||||
})
|
||||
|
@ -1373,7 +1373,7 @@ impl IdlSqlite {
|
|||
})?;
|
||||
|
||||
vconn
|
||||
.pragma_update(None, "journal_mode", &"DELETE")
|
||||
.pragma_update(None, "journal_mode", "DELETE")
|
||||
.map_err(|e| {
|
||||
admin_error!(?e, "rusqlite journal_mode update error");
|
||||
OperationError::SqliteError
|
||||
|
@ -1388,7 +1388,7 @@ impl IdlSqlite {
|
|||
Connection::open_with_flags(cfg.path.as_str(), flags).map_err(sqlite_error)?;
|
||||
|
||||
vconn
|
||||
.pragma_update(None, "page_size", &(cfg.fstype as u32))
|
||||
.pragma_update(None, "page_size", cfg.fstype as u32)
|
||||
.map_err(|e| {
|
||||
admin_error!(?e, "rusqlite page_size update error");
|
||||
OperationError::SqliteError
|
||||
|
@ -1400,7 +1400,7 @@ impl IdlSqlite {
|
|||
})?;
|
||||
|
||||
vconn
|
||||
.pragma_update(None, "journal_mode", &"WAL")
|
||||
.pragma_update(None, "journal_mode", "WAL")
|
||||
.map_err(|e| {
|
||||
admin_error!(?e, "rusqlite journal_mode update error");
|
||||
OperationError::SqliteError
|
||||
|
|
|
@ -465,7 +465,8 @@ impl Oauth2ResourceServersReadTransaction {
|
|||
//
|
||||
let o2rs = self.inner.rs_set.get(&auth_req.client_id).ok_or_else(|| {
|
||||
admin_warn!(
|
||||
"Invalid oauth2 client_id (have you configured the oauth2 resource server?)"
|
||||
"Invalid oauth2 client_id ({}) Have you configured the oauth2 resource server?",
|
||||
&auth_req.client_id
|
||||
);
|
||||
Oauth2Error::InvalidClientId
|
||||
})?;
|
||||
|
@ -474,7 +475,9 @@ impl Oauth2ResourceServersReadTransaction {
|
|||
if auth_req.redirect_uri.origin() != o2rs.origin {
|
||||
admin_warn!(
|
||||
origin = ?o2rs.origin,
|
||||
"Invalid oauth2 redirect_uri (must be related to origin of) - got {:?}", auth_req.redirect_uri.origin()
|
||||
"Invalid oauth2 redirect_uri (must be related to origin {:?}) - got {:?}",
|
||||
o2rs.origin,
|
||||
auth_req.redirect_uri.origin()
|
||||
);
|
||||
return Err(Oauth2Error::InvalidOrigin);
|
||||
}
|
||||
|
|
|
@ -1577,6 +1577,7 @@ impl<'a> IdmServerTransaction<'a> for IdmServerProxyWriteTransaction<'a> {
|
|||
|
||||
impl<'a> IdmServerProxyWriteTransaction<'a> {
|
||||
pub fn get_origin(&self) -> &Url {
|
||||
#[allow(clippy::unwrap_used)]
|
||||
self.webauthn.get_allowed_origins().get(0).unwrap()
|
||||
}
|
||||
|
||||
|
@ -2131,8 +2132,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
|||
|
||||
let mlist: Vec<_> = sessions
|
||||
.iter()
|
||||
.map(|item| item.iter())
|
||||
.flatten()
|
||||
.flat_map(|item| item.iter())
|
||||
.filter_map(|(k, v)| {
|
||||
// We only check if an expiry is present
|
||||
v.expiry.and_then(|exp| {
|
||||
|
|
|
@ -205,10 +205,7 @@ impl<'a> IdmServerProxyWriteTransaction<'a> {
|
|||
let issued_at = time::OffsetDateTime::unix_epoch() + ct;
|
||||
|
||||
// Normalise to UTC incase it was provided as something else.
|
||||
let expiry = gte
|
||||
.expiry
|
||||
.clone()
|
||||
.map(|odt| odt.to_offset(time::UtcOffset::UTC));
|
||||
let expiry = gte.expiry.map(|odt| odt.to_offset(time::UtcOffset::UTC));
|
||||
|
||||
let purpose = if gte.read_write {
|
||||
ApiTokenPurpose::ReadWrite
|
||||
|
|
|
@ -15,6 +15,7 @@ pub struct DynGroupCache {
|
|||
pub struct DynGroup;
|
||||
|
||||
impl DynGroup {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn apply_dyngroup_change(
|
||||
qs: &QueryServerWriteTransaction,
|
||||
ident: &Identity,
|
||||
|
@ -35,7 +36,7 @@ impl DynGroup {
|
|||
// Search all the new groups first.
|
||||
let filt = filter!(FC::Or(
|
||||
n_dyn_groups
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|e| f_eq("uuid", PartialValue::new_uuid(e.get_uuid())))
|
||||
.collect()
|
||||
));
|
||||
|
|
|
@ -4,8 +4,9 @@ use crate::schema::Schema;
|
|||
#[allow(unused_imports)]
|
||||
use crate::utils::duration_from_epoch_now;
|
||||
|
||||
#[allow(clippy::expect_used)]
|
||||
pub async fn setup_test() -> QueryServer {
|
||||
let _ = sketching::test_init();
|
||||
sketching::test_init();
|
||||
|
||||
// Create an in memory BE
|
||||
let schema_outer = Schema::new().expect("Failed to init schema");
|
||||
|
@ -15,17 +16,16 @@ pub async fn setup_test() -> QueryServer {
|
|||
};
|
||||
let be = Backend::new(BackendConfig::new_test(), idxmeta, false).expect("Failed to init BE");
|
||||
|
||||
let qs = QueryServer::new(be, schema_outer, "example.com".to_string());
|
||||
// Init is called via the proc macro
|
||||
qs
|
||||
QueryServer::new(be, schema_outer, "example.com".to_string())
|
||||
}
|
||||
|
||||
#[allow(clippy::expect_used)]
|
||||
pub async fn setup_idm_test() -> (IdmServer, IdmServerDelayed) {
|
||||
let qs = setup_test().await;
|
||||
|
||||
qs.initialise_helper(duration_from_epoch_now())
|
||||
.await
|
||||
.expect("init failed!");
|
||||
|
||||
IdmServer::new(qs, "https://idm.example.com").expect("Failed to setup idms")
|
||||
}
|
||||
|
|
|
@ -735,6 +735,7 @@ impl PartialValue {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::unimplemented)]
|
||||
pub fn get_idx_sub_key(&self) -> String {
|
||||
unimplemented!();
|
||||
}
|
||||
|
|
|
@ -647,7 +647,7 @@ pub fn from_db_valueset_v2(dbvs: DbValueSetV2) -> Result<ValueSet, OperationErro
|
|||
DbValueSetV2::JwsKeyEs256(set) => ValueSetJwsKeyEs256::from_dbvs2(&set),
|
||||
DbValueSetV2::JwsKeyRs256(set) => ValueSetJwsKeyEs256::from_dbvs2(&set),
|
||||
DbValueSetV2::PhoneNumber(_, _) | DbValueSetV2::TrustedDeviceEnrollment(_) => {
|
||||
unimplemented!()
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ pub(crate) fn test(_args: &TokenStream, item: TokenStream) -> TokenStream {
|
|||
|
||||
if let Some(attr) = input.attrs.iter().find(|attr| attr.path.is_ident("test")) {
|
||||
let msg = "second test attribute is supplied";
|
||||
return token_stream_with_error(item, syn::Error::new_spanned(&attr, msg));
|
||||
return token_stream_with_error(item, syn::Error::new_spanned(attr, msg));
|
||||
};
|
||||
|
||||
if input.sig.asyncness.is_none() {
|
||||
|
|
|
@ -288,7 +288,7 @@ impl ChangeUnixPassword {
|
|||
let headers = resp.headers();
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ impl DeleteApp {
|
|||
Ok(Msg::Success)
|
||||
} else {
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ impl PasskeyModalApp {
|
|||
})
|
||||
} else {
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ impl PasskeyRemoveModalApp {
|
|||
})
|
||||
} else {
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ impl PwModalApp {
|
|||
} else {
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -563,7 +563,7 @@ impl CredentialResetApp {
|
|||
} else {
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ impl CredentialResetApp {
|
|||
} else {
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ impl TotpModalApp {
|
|||
})
|
||||
} else {
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ impl LoginApp {
|
|||
} else {
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(LoginAppMsg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,10 +52,15 @@ fn switch(route: &Route) -> Html {
|
|||
#[cfg(debug)]
|
||||
console::debug!("manager::switch");
|
||||
match route {
|
||||
#[allow(clippy::let_unit_value)]
|
||||
Route::Landing => html! { <Landing /> },
|
||||
#[allow(clippy::let_unit_value)]
|
||||
Route::Login => html! { <LoginApp /> },
|
||||
#[allow(clippy::let_unit_value)]
|
||||
Route::Oauth2 => html! { <Oauth2App /> },
|
||||
#[allow(clippy::let_unit_value)]
|
||||
Route::Views => html! { <ViewsApp /> },
|
||||
#[allow(clippy::let_unit_value)]
|
||||
Route::CredentialReset => html! { <CredentialResetApp /> },
|
||||
Route::NotFound => {
|
||||
add_body_form_classes!();
|
||||
|
|
|
@ -92,7 +92,7 @@ impl Oauth2App {
|
|||
let headers = resp.headers();
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
// let jsval_json = JsFuture::from(resp.json()?).await?;
|
||||
Ok(Oauth2Msg::Error { emsg, kopid })
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ impl Oauth2App {
|
|||
Ok(Oauth2Msg::AccessDenied { kopid })
|
||||
} else {
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Oauth2Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,6 +320,7 @@ impl ViewsApp {
|
|||
ViewRoute::Admin => html!{
|
||||
<Switch<AdminRoute> render={ Switch::render(admin_routes) } />
|
||||
},
|
||||
#[allow(clippy::let_unit_value)]
|
||||
ViewRoute::Apps => html! { <AppsApp /> },
|
||||
ViewRoute::Profile => html! { <ProfileApp current_user_uat={ current_user_uat.clone() } /> },
|
||||
ViewRoute::Security => html! { <SecurityApp current_user_uat={ current_user_uat.clone() } /> },
|
||||
|
@ -359,7 +360,7 @@ impl ViewsApp {
|
|||
let headers = resp.headers();
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(ViewsMsg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
@ -396,7 +397,7 @@ impl ViewsApp {
|
|||
let headers = resp.headers();
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(ViewsMsg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
@ -425,7 +426,7 @@ impl ViewsApp {
|
|||
let headers = resp.headers();
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(ViewsMsg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ impl TryFrom<Entry> for Profile {
|
|||
type Error = String;
|
||||
|
||||
fn try_from(entry: Entry) -> Result<Self, Self::Error> {
|
||||
console::error!("Entry Dump", format!("{:?}", entry).to_string());
|
||||
console::error!("Entry Dump", format!("{:?}", entry));
|
||||
|
||||
let uuid = entry
|
||||
.attrs
|
||||
|
@ -152,7 +152,7 @@ impl Component for ProfileApp {
|
|||
</main>
|
||||
}
|
||||
}
|
||||
State::Ready(profile) => self.view_profile(ctx, &profile),
|
||||
State::Ready(profile) => self.view_profile(ctx, profile),
|
||||
State::Error { emsg, kopid } => self.do_alert_error(
|
||||
"An error has occured 😔 ",
|
||||
Some(
|
||||
|
@ -313,7 +313,7 @@ impl ProfileApp {
|
|||
let headers = resp.headers();
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ impl SecurityApp {
|
|||
let headers = resp.headers();
|
||||
let kopid = headers.get("x-kanidm-opid").ok().flatten();
|
||||
let text = JsFuture::from(resp.text()?).await?;
|
||||
let emsg = text.as_string().unwrap_or_else(|| "".to_string());
|
||||
let emsg = text.as_string().unwrap_or_default();
|
||||
// let jsval_json = JsFuture::from(resp.json()?).await?;
|
||||
Ok(Msg::Error { emsg, kopid })
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ impl TargetServerBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum TargetServer {
|
||||
Kanidm(KaniHttpServer),
|
||||
KanidmLdap(Box<KaniLdapServer>),
|
||||
|
|
Loading…
Reference in a new issue