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

[PM-7840] Implement the stubbed out Passkey uniffi API #779

Merged
merged 41 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
419101d
Improvements to Passkey uniffi API
dani-garcia May 3, 2024
d2041a3
Here we go again with the uniffi workaround
dani-garcia May 13, 2024
07642dc
Remove stub credential
dani-garcia May 13, 2024
9e704a4
Add a warning about silent discover
dani-garcia May 13, 2024
c21f94a
Changes based on review
dani-garcia May 14, 2024
26a3c63
Fmt
dani-garcia May 14, 2024
16b8b03
Change API based on latest spec
dani-garcia May 14, 2024
27ca115
Update passkey-rs and respect the UV value provided in get_assertion …
dani-garcia May 14, 2024
c63d806
Update passkey-rs for async is_verification_enabled
dani-garcia May 14, 2024
82dac1b
Merge branch 'main' into ps/uniffi-passkey-improvements
dani-garcia May 14, 2024
3a82eec
Handle URL parse error
dani-garcia May 14, 2024
77f07a0
Return valid authenticator data
dani-garcia May 14, 2024
499ebb9
Use valid error codes
dani-garcia May 14, 2024
5478d3c
Merge branch 'main' into ps/uniffi-passkey-improvements
dani-garcia May 14, 2024
3a03ba5
Remove unneeded require_resident_key field
dani-garcia May 15, 2024
2832bcf
Change where we transform UV (#786)
coroiu May 15, 2024
ad3e4de
Actually call pick_credential_for_authentication
dani-garcia May 15, 2024
1e8c37f
Remove crypto copied from passkey-rs
dani-garcia May 17, 2024
55938d6
Fix some review comments
dani-garcia May 17, 2024
aa48fce
Implement UIHint
dani-garcia May 20, 2024
ea7ca9e
Formatting
dani-garcia May 20, 2024
e537b6f
Merge branch 'main' into ps/uniffi-passkey-improvements
dani-garcia May 23, 2024
1d90784
Improve error handling, don't panic when an exception is thrown
dani-garcia May 23, 2024
54f511a
Make p256 optional
dani-garcia May 23, 2024
01b12f1
Improve ClientData comment
dani-garcia May 23, 2024
5c5c386
Update swift example
dani-garcia May 23, 2024
10fa9f7
Merge branch 'main' into ps/uniffi-passkey-improvements
dani-garcia May 24, 2024
2a448bd
Remove some todos
dani-garcia May 24, 2024
a7b21d3
Remove some more todos
dani-garcia May 24, 2024
8caaeed
requested_uv and uv conversion
dani-garcia May 24, 2024
5143d1d
Remove comments
dani-garcia May 27, 2024
c9fa74b
Merge branch 'main' into ps/uniffi-passkey-improvements
dani-garcia May 29, 2024
432e06a
Remove some unnecessary locks and takes
dani-garcia May 29, 2024
99b7f56
Simplify ClientData
dani-garcia May 29, 2024
7a4b8b1
Update pick_credential_for_creation, move functions to check_user, in…
dani-garcia May 30, 2024
2d297b7
Support b64 credential IDs
dani-garcia May 30, 2024
acafb94
Merge branch 'main' into ps/uniffi-passkey-improvements
dani-garcia Jun 3, 2024
7a2680f
Update iOS example
dani-garcia Jun 3, 2024
e111192
Merge branch 'main' into ps/uniffi-passkey-improvements
dani-garcia Jun 3, 2024
75dc8d3
Update passkey-rs
dani-garcia Jun 3, 2024
f852dbf
Validate that the provided credential ID matches what is stored
dani-garcia Jun 4, 2024
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
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions crates/bitwarden-uniffi/src/platform/fido2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
impl ClientFido2 {
pub fn authenticator(
self: Arc<Self>,
user_interface: Arc<dyn UserInterface>,
credential_store: Arc<dyn CredentialStore>,
user_interface: Arc<dyn Fido2UserInterface>,
credential_store: Arc<dyn Fido2CredentialStore>,

Check warning on line 26 in crates/bitwarden-uniffi/src/platform/fido2.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/platform/fido2.rs#L25-L26

Added lines #L25 - L26 were not covered by tests
) -> Arc<ClientFido2Authenticator> {
Arc::new(ClientFido2Authenticator(
self.0.clone(),
Expand All @@ -34,8 +34,8 @@

pub fn client(
self: Arc<Self>,
user_interface: Arc<dyn UserInterface>,
credential_store: Arc<dyn CredentialStore>,
user_interface: Arc<dyn Fido2UserInterface>,
credential_store: Arc<dyn Fido2CredentialStore>,

Check warning on line 38 in crates/bitwarden-uniffi/src/platform/fido2.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/platform/fido2.rs#L37-L38

Added lines #L37 - L38 were not covered by tests
) -> Arc<ClientFido2Client> {
Arc::new(ClientFido2Client(ClientFido2Authenticator(
self.0.clone(),
Expand All @@ -48,8 +48,8 @@
#[derive(uniffi::Object)]
pub struct ClientFido2Authenticator(
pub(crate) Arc<Client>,
pub(crate) Arc<dyn UserInterface>,
pub(crate) Arc<dyn CredentialStore>,
pub(crate) Arc<dyn Fido2UserInterface>,
pub(crate) Arc<dyn Fido2CredentialStore>,
);

#[uniffi::export]
Expand Down Expand Up @@ -154,7 +154,7 @@

#[uniffi::export(with_foreign)]
#[async_trait::async_trait]
pub trait UserInterface: Send + Sync {
pub trait Fido2UserInterface: Send + Sync {
async fn check_user(
&self,
options: CheckUserOptions,
Expand All @@ -169,11 +169,12 @@
available_credentials: Vec<CipherView>,
new_credential: Fido2CredentialNewView,
) -> Result<CipherViewWrapper>;
async fn is_verification_enabled(&self) -> bool;
}

#[uniffi::export(with_foreign)]
#[async_trait::async_trait]
pub trait CredentialStore: Send + Sync {
pub trait Fido2CredentialStore: Send + Sync {
async fn find_credentials(
&self,
ids: Option<Vec<Vec<u8>>>,
Expand All @@ -190,12 +191,14 @@
struct UniffiTraitBridge<T>(T);

#[async_trait::async_trait]
impl bitwarden::platform::fido2::CredentialStore for UniffiTraitBridge<&dyn CredentialStore> {
impl bitwarden::platform::fido2::Fido2CredentialStore
for UniffiTraitBridge<&dyn Fido2CredentialStore>
{
async fn find_credentials(
&self,
ids: Option<Vec<Vec<u8>>>,
rip_id: String,
) -> BitResult<Vec<CipherView>> {

Check warning on line 201 in crates/bitwarden-uniffi/src/platform/fido2.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/platform/fido2.rs#L201

Added line #L201 was not covered by tests
self.0
.find_credentials(ids, rip_id)
.await
Expand All @@ -217,7 +220,7 @@
}

#[async_trait::async_trait]
impl bitwarden::platform::fido2::UserInterface for UniffiTraitBridge<&dyn UserInterface> {
impl bitwarden::platform::fido2::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInterface> {
async fn check_user(
&self,
options: CheckUserOptions,
Expand Down Expand Up @@ -253,4 +256,7 @@
.map(|v| v.cipher)
.map_err(Into::into)
}
async fn is_verification_enabled(&self) -> bool {
self.0.is_verification_enabled().await
}

Check warning on line 261 in crates/bitwarden-uniffi/src/platform/fido2.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/platform/fido2.rs#L259-L261

Added lines #L259 - L261 were not covered by tests
}
2 changes: 1 addition & 1 deletion crates/bitwarden/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ getrandom = { version = ">=0.2.9, <0.3", features = ["js"] }
hmac = ">=0.12.1, <0.13"
log = ">=0.4.18, <0.5"
p256 = ">=0.13.2, <0.14"
passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "12da886102707f87ad97e499c857c0857ece0b85", optional = true }
passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "f8ce4fcf25734bd38ebc42a6821d290bc82d30e6", optional = true }
rand = ">=0.8.5, <0.9"
reqwest = { version = ">=0.12, <0.13", features = [
"http2",
Expand Down
Loading
Loading