Skip to content

Commit f8959b0

Browse files
brotskydotcomkornelski
authored andcommitted
Add ItemSearchOptions support for skipping authenticated items.
Fixes #231.
1 parent 558070b commit f8959b0

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

security-framework/src/item.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ pub struct ItemSearchOptions {
146146
app_label: Option<CFData>,
147147
#[cfg(any(feature = "OSX_10_13", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
148148
authentication_context: Option<CFType>,
149+
#[cfg(any(feature = "OSX_10_12", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
150+
skip_authenticated_items: bool,
149151
}
150152

151153
#[cfg(target_os = "macos")]
@@ -309,6 +311,14 @@ impl ItemSearchOptions {
309311
self
310312
}
311313

314+
/// Whether to skip items in the search that require authentication (default false)
315+
#[inline(always)]
316+
#[cfg(any(feature = "OSX_10_12", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
317+
pub fn skip_authenticated_items(&mut self, do_skip: bool) -> &mut Self {
318+
self.skip_authenticated_items = do_skip;
319+
self
320+
}
321+
312322
/// Populates a `CFDictionary` to be passed to `update_item` or `delete_item`.
313323
// CFDictionary should not be exposed in public Rust APIs.
314324
#[inline]
@@ -407,6 +417,11 @@ impl ItemSearchOptions {
407417
params.add(&kSecUseAuthenticationContext.to_void(), &authentication_context.to_void());
408418
}
409419

420+
#[cfg(any(feature = "OSX_10_12", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
421+
if self.skip_authenticated_items {
422+
params.add(&kSecUseAuthenticationUI.to_void(), &kSecUseAuthenticationUISkip.to_void());
423+
}
424+
410425
params.to_immutable()
411426
}
412427
}

0 commit comments

Comments
 (0)