Skip to content

Commit

Permalink
[SM-1338] Add the ability to edit unassigned secrets (#906)
Browse files Browse the repository at this point in the history
## 🎟️ Tracking

<!-- Paste the link to the Jira or GitHub issue or otherwise describe /
point to where this change is coming from. -->
https://bitwarden.atlassian.net/browse/SM-1338

## 📔 Objective

<!-- Describe what the purpose of this PR is, for example what bug
you're fixing or new feature you're adding. -->
With the introduction of individual secret permissions, it is possible
for a machine account to have **read, write** permission on an
unassigned secret.
Editing this unassigned secret should be supported by `bws`.
This removes the client side validation that restricted the edit of an
unassigned secret.
  • Loading branch information
Thomas-Avery authored Jul 19, 2024
1 parent 27a71d8 commit 5e5ddab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 4 additions & 0 deletions crates/bws/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- The ability to edit unassigned secrets with direct permissions. (#906)

### Removed

- The deprecated `action type` commands are now removed. Please use `type action` instead. (#836)
Expand Down
11 changes: 4 additions & 7 deletions crates/bws/src/command/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,10 @@ pub(crate) async fn edit(
key: secret.key.unwrap_or(old_secret.key),
value: secret.value.unwrap_or(old_secret.value),
note: secret.note.unwrap_or(old_secret.note),
project_ids: match secret.project_id {
Some(id) => Some(vec![id]),
None => match old_secret.project_id {
Some(id) => Some(vec![id]),
None => bail!("Editing a secret requires a project_id."),
},
},
project_ids: secret
.project_id
.or(old_secret.project_id)
.map(|id| vec![id]),
})
.await?;
serialize_response(new_secret, output_settings);
Expand Down

0 comments on commit 5e5ddab

Please sign in to comment.