-
Notifications
You must be signed in to change notification settings - Fork 50
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
SM-866: Add state to the SDK & BWS CLI #388
Conversation
New Issues
Fixed Issues
|
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.
Some quick review comments
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 had hoped we could leave the bitwarden
crate mostly untouched and have the state mostly in the bws
crate.
We will have the same problem with the PHP bindings, so having a solution just for |
Yeah, that's why I tried to leave "minimal" changes in the bitwarden crate, and a lot of the storage logic is in bws. However, as @dani-garcia mentioned, multiple integrations will need to be able to use state to avoid the reauthentication each time (PHP and Python specifically have been discussed).
Update (Dec 5): PR has been updated, most of the logic is in the |
## Type of change <!-- (mark with an `X`) --> ``` - [ ] Bug fix - [ ] New feature development - [x] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> Refactor out the `Instant` type in Client and use unix timestamps. This is to support this PR: #388 where we need to serialize token expiry times. It also brings benefits to other areas like WASM, where `Instant` doesn't exist. ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> - **crates/bitwarden/src/auth/renew.rs:** Update the `renew_token` function to use timestamps instead of the `Instant` type - **crates/bitwarden/src/client/client.rs:** Update `Client` to store the unix timestamp for token expiration ## Before you submit - Please add **unit tests** where it makes sense to do so (encouraged but not required)
…commit to save work.
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.
Some minor things to avoid some unneeded clones but otherwise LGTM
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #388 +/- ##
==========================================
- Coverage 45.45% 44.81% -0.64%
==========================================
Files 149 151 +2
Lines 6771 6881 +110
==========================================
+ Hits 3078 3084 +6
- Misses 3693 3797 +104 ☔ View full report in Codecov by Sentry. |
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.
Looks good, ideally we would have test cases for the new access token login logic, and ClientState logic.
## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [x] Other ## Objective Enable authentication with the state file. Relates to #388. ## Code changes - **`languages/python/bitwarden_sdk/bitwarden_client.py`**: Add optional `state_file_path` parameter to `access_token_login` ## Before you submit - Please add **unit tests** where it makes sense to do so --------- Co-authored-by: Daniel García <dani-garcia@users.noreply.github.com>
Type of change
Objective
This PR adds the ability to manage basic state via the SDK. It also updates the
bws
crate to use this SDK change, implementing basic state management for auth tokens. The core benefit is that reauthentication per command will no longer be needed, so that server auth requests will be mitigated.Code changes
(to be added)
Before you submit