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

[bitwarden] ability to fetch all fields from an item #994

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

honzasterba
Copy link
Contributor

Sometimes a projects has a lot of secrets (more than 10). And its cumbersome to write $(kama secrets fetch ...) with a lot of field names.

I want to be able to just fetch all the fields from a given item and then just use these with $(kamal extract NAME)

@@ -29,6 +29,7 @@ def fetch_secrets(secrets, account:, session:)
item_json = JSON.parse(item_json)

if fields.any?
fields = item_json["fields"].pluck("name") if fields == [ "__ALL__" ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can just allow the name to be passed without any fields and then return all the values - so something like this:

          elsif (item_fields = item_json.dig("fields"))
            item_fields.each do |item_field|
              results["#{item}/#{item_field["name"]}"] = item_field["value"]
            end
          else

Then we can avoid the special __ALL__ value and you can say:

SECRETS=$(kamal secrets fetch --adapter bitwarden --account email@example.com ITEM)
FIELD1=$(kamal secrets extract FIELD1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is in conflict with the current code which just defaults to extracting a password from the item selected
currently secrets fetch ITEM returns a hash {"ITEM" => "password from item"} for login item, otherwise an error
another idea I had was to add it as an arg option kamal secrets fetch --all-fields ITEM not sure how feasible that is as it would impact the overall adapter API
another idea is to do make secrets fetch ITEM return all the fields as { "FIELD_1" => val, ... } if the item is not a Login item, that would not break compatibility
WDYT?

Sometimes a projects has a lot of secrets (more than 10). And its
cumbersome to write $(kama secrets fetch ...) with a lot of field names.

I want to be able to just fetch all the fields from a given item and then
just use these with $(kamal extract NAME)
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