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-7143] Add support for provider side forced uv to support password reprompt #5

Conversation

coroiu
Copy link
Collaborator

@coroiu coroiu commented Apr 16, 2024

…ationMethod`

@coroiu coroiu force-pushed the PM-7143-add-support-for-provider-side-forced-uv-to-support-password-reprompt branch from 2dd0201 to 6c153c6 Compare April 16, 2024 12:20
Copy link
Member

@dani-garcia dani-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some general comments, I tried to solve some of the Send+Sync issues by adding some extra bounds. Got it compiling but some tests fail, here's the diff:

diff --git a/passkey-authenticator/src/credential_store.rs b/passkey-authenticator/src/credential_store.rs
index 060c6da..15ce765 100644
--- a/passkey-authenticator/src/credential_store.rs
+++ b/passkey-authenticator/src/credential_store.rs
@@ -14,7 +14,7 @@ use passkey_types::{
 #[async_trait::async_trait]
 pub trait CredentialStore {
     /// Defines the return type of find_credentials(...)
-    type PasskeyItem: TryInto<Passkey> + Clone;
+    type PasskeyItem: TryInto<Passkey> + Send + Clone;
 
     /// Find all credentials matching the given `ids` and `rp_id`.
     ///
diff --git a/passkey-client/src/lib.rs b/passkey-client/src/lib.rs
index 8654d62..1898fb9 100644
--- a/passkey-client/src/lib.rs
+++ b/passkey-client/src/lib.rs
@@ -103,7 +103,7 @@ where
     S: CredentialStore + Sync,
     U: UserValidationMethod + Sync,
     P: public_suffix::EffectiveTLDProvider + Sync + 'static,
-    Passkey: TryFrom<<S as CredentialStore>::PasskeyItem>,
+    Passkey: TryFrom<<S as CredentialStore>::PasskeyItem> + Send + Clone,
 {
     authenticator: Authenticator<S, U>,
     rp_id_verifier: RpIdVerifier<P>,
@@ -113,7 +113,7 @@ impl<S, U> Client<S, U, public_suffix::PublicSuffixList>
 where
     S: CredentialStore + Sync,
     U: UserValidationMethod + Sync,
-    Passkey: TryFrom<<S as CredentialStore>::PasskeyItem>,
+    Passkey: TryFrom<<S as CredentialStore>::PasskeyItem> + Send + Clone,
 {
     /// Create a `Client` with a given `Authenticator` that uses the default
     /// TLD verifier provided by `[public_suffix]`.
@@ -128,9 +128,9 @@ where
 impl<S, U, P> Client<S, U, P>
 where
     S: CredentialStore + Sync,
-    U: UserValidationMethod + Sync,
+    U: UserValidationMethod<PasskeyItem = <S as CredentialStore>::PasskeyItem> + Send + Sync,
     P: public_suffix::EffectiveTLDProvider + Sync + 'static,
-    Passkey: TryFrom<<S as CredentialStore>::PasskeyItem>,
+    Passkey: TryFrom<<S as CredentialStore>::PasskeyItem> + Send + Clone,
 {
     /// Create a `Client` with a given `Authenticator` and a custom TLD provider
     /// that implements `[public_suffix::EffectiveTLDProvider]`.

passkey-authenticator/src/authenticator/get_assertion.rs Outdated Show resolved Hide resolved
passkey-authenticator/src/user_validation.rs Show resolved Hide resolved
passkey-authenticator/src/user_validation.rs Show resolved Hide resolved
Comment on lines +30 to +35
mockall = { version = "0.11", optional = true }
typeshare = "1"
idna = "0.5"
url = "2"
coset = "0.3"
tokio = { version = "1", features = ["sync"], optional = true }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

point-of-interest: I'm not exactly sure why I had to add mockall and tokio to passkey-client, but it was the only way I could get it to compile after I added #[tokio::test] in authenticator.rs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason they need to be added is that they are declared as dependencies for the two added features:

tokio = ["dep:tokio"]
testable = ["dep:mockall"]

Those features seem to me like they aren't used anywhere in the passkey-client crate so they can be removed and that means tokio and mockall can be removed from the [dependencies] section.

mockall still needs to be in [dev-dependencies] as it's used here:

mockall::predicate::always(),
mockall::predicate::eq(true),
mockall::predicate::eq(true),

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah exactly, but if I do that then those lines give me an error, that's what confuses me

image

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm weird, passkey-authenticator also has them as normal optional dependencies too, so I guess it makes sense to follow that established pattern anyway.

@coroiu coroiu force-pushed the PM-7143-add-support-for-provider-side-forced-uv-to-support-password-reprompt branch 2 times, most recently from 0e2a41e to cea73a2 Compare April 18, 2024 12:14
@coroiu coroiu force-pushed the PM-7143-add-support-for-provider-side-forced-uv-to-support-password-reprompt branch from cea73a2 to e7703a6 Compare April 18, 2024 13:19
@coroiu coroiu marked this pull request as ready for review April 18, 2024 13:20
@coroiu coroiu requested a review from dani-garcia April 18, 2024 13:20
Copy link
Member

@dani-garcia dani-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one small nit

passkey-authenticator/src/authenticator/get_assertion.rs Outdated Show resolved Hide resolved
@coroiu coroiu requested a review from dani-garcia April 23, 2024 11:03
@coroiu coroiu merged commit e875a07 into main Apr 23, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants