-
Notifications
You must be signed in to change notification settings - Fork 49
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
Make client internally mutable #837
Conversation
No New Or Fixed Issues Found |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #837 +/- ##
==========================================
+ Coverage 59.22% 60.07% +0.85%
==========================================
Files 186 186
Lines 12396 12246 -150
==========================================
+ Hits 7341 7357 +16
+ Misses 5055 4889 -166 ☔ View full report in Codecov by Sentry. |
# Conflicts: # crates/bitwarden-uniffi/src/crypto.rs # crates/bitwarden-uniffi/src/tool/mod.rs # crates/bitwarden-uniffi/src/tool/sends.rs # crates/bitwarden-uniffi/src/vault/attachments.rs # crates/bitwarden-uniffi/src/vault/ciphers.rs # crates/bitwarden-uniffi/src/vault/collections.rs # crates/bitwarden-uniffi/src/vault/folders.rs # crates/bitwarden/src/mobile/client_crypto.rs # crates/bitwarden/src/mobile/tool/client_sends.rs
token: RwLock<Option<String>>, | ||
pub(crate) refresh_token: RwLock<Option<String>>, | ||
pub(crate) token_expires_on: RwLock<Option<i64>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should find some way to group these together. You shouldn't be able to write to just one of these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's true, I extracted them to a tokens struct, which at least simplifies a bit all the locking and unlocking.
# Conflicts: # crates/bitwarden/src/client/client.rs # crates/bitwarden/src/platform/fido2/authenticator.rs # crates/bitwarden/src/platform/fido2/mod.rs
📔 Objective
We're having some deadlock problems with the Passkey API by calling certain SDK functions on the
passkey-rs
callbacks. These issues are caused because we're holding a reference to the RwLock during the execution of the Passkey operation and so calling into the SDK from inside that will deadlock.To solve it we can't just use a lock at the client level, and so we need to move to using interior mutability, I've revived an old PR (#70) where we started doing that.
This PR is split into two commits, for ease of review:
&mut
references used in the bitwarden Client API. Note that this alone won't compile.Some notes of what the change entails:
EncryptionSettings
in aRwLock<Arc<>>
to get the API working, this is quite unfortunate as it forces us to cloneEncryptionSettings
to modify it when callingset_org_keys
. We can't wrap theorg_keys
in aRwLock
as we will get lifetime issues inget_key
. I think the best solution for this will be the work on creating a Crypto store that only returns opaque key references, so we might want to prioritize that.external_client
fromApiConfigurations
, as it's never mutated and it allows us to keep the same API forget_http_client
I hate that
Mutex
andRwLock
return a Result in case they are poisoned, that's never our case and it makes their usage so cumbersome 😢Note: I've tried to change the smallest amount of code to make the change, so the secrets manager APIs (and bitwarden-json) are still mutable. If we're okay with these changes I can go back to update those in a separate PR.
⏰ Reminders before review
team
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmedissue and could potentially benefit from discussion
:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes