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

Add Support to Bitwarden Lookup for Custom Fields #5694

Merged
merged 7 commits into from
Jan 7, 2023

Conversation

reverendj1
Copy link
Contributor

SUMMARY

Currently the Bitwarden lookup plugin only searches for fields in the login key (password, passwordRevisionDate, totp, urs, username). It is not uncommon to create custom fields in Bitwarden, for things such as api keys, which we should also be able to look up. I tried to make the lookup work seamlessly across custom or standard fields, so it does not add complexity for the user.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

bitwarden

ADDITIONAL INFORMATION

Example code :

- debug:
    msg: |
      Full record: {{ lookup('community.general.bitwarden', 'MI6 Secrets') | first | to_nice_yaml }}
      Username: {{ lookup('community.general.bitwarden', 'MI6 Secrets', field="username") | first }}
      Password: {{ lookup('community.general.bitwarden', 'MI6 Secrets', field="password") | first }}
      Custom Field (pin_code): {{ lookup('community.general.bitwarden', 'MI6 Secrets', field="pin_code") | first }}

Example output:

TASK [debug] **************************************************************************************************************************************************************************
changed: [localhost] => 
  msg: |-
    Full record: collectionIds: []
    favorite: false
    fields:
    -   name: pin_code
        type: 0
        value: '1234'
    folderId: null
    id: f22421bb-c99c-4bc1-afa9-c52ad43ead2c
    login:
        password: 007JawsSucks
        passwordRevisionDate: null
        totp: null
        uris:
        -   match: null
            uri: https://mi6.uk
        username: jamesbond
    name: MI6 Secrets
    notes: null
    object: item
    organizationId: null
    revisionDate: '2022-12-16T20:30:33.823Z'
    type: 1
  
    Username: jamesbond
    Password: 007JawsSucks
    Custom Field (pin_code): 1234

This adds support to the Bitwarden lookup for retrieving values from
custom fields, such as api keys.
@ansibullbot
Copy link
Collaborator

cc @lungj
click here for bot help

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request lookup lookup plugin new_contributor Help guide this first time contributor plugins plugin (any type) labels Dec 16, 2022
@github-actions
Copy link

github-actions bot commented Dec 16, 2022

Docs Build 📝

Thank you for contribution!✨

The docsite for this PR is available for download as an artifact from this run:
https://github.com/ansible-collections/community.general/actions/runs/3759194010

File changes:

  • M collections/community/general/ansible_galaxy_install_module.html
  • M collections/community/general/bitwarden_lookup.html
  • M collections/community/general/github_release_module.html
  • M collections/community/general/manageiq_policies_module.html
  • M collections/community/general/sudoers_module.html
Click to see the diff comparison.

NOTE: only file modifications are shown here. New and deleted files are excluded.
See the file list and check the published docs to see those files.

diff --git a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/ansible_galaxy_install_module.html b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/ansible_galaxy_install_module.html
index c5da720..7b59295 100644
--- a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/ansible_galaxy_install_module.html
+++ b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/ansible_galaxy_install_module.html
@@ -286,6 +286,7 @@ see <a class="reference internal" href="#ansible-collections-community-general-a
 <p class="admonition-title">Note</p>
 <ul class="simple">
 <li><p><strong>Ansible 2.9/2.10</strong>: The <code class="docutils literal notranslate"><span class="pre">ansible-galaxy</span></code> command changed significantly between Ansible 2.9 and ansible-base 2.10 (later ansible-core 2.11). See comments in the parameters.</p></li>
+<li><p>The module will try and run using the <code class="docutils literal notranslate"><span class="pre">C.UTF-8</span></code> locale. If that fails, it will try <code class="docutils literal notranslate"><span class="pre">en_US.UTF-8</span></code>. If that one also fails, the module will fail.</p></li>
 </ul>
 </div>
 </section>
diff --git a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/bitwarden_lookup.html b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/bitwarden_lookup.html
index 7f61a3f..48dd7e7 100644
--- a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/bitwarden_lookup.html
+++ b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/bitwarden_lookup.html
@@ -233,6 +233,11 @@ see <a class="reference internal" href="#ansible-collections-community-general-b
 <span class="w">  </span><span class="nt">ansible.builtin.debug</span><span class="p">:</span><span class="w"></span>
 <span class="w">    </span><span class="nt">msg</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">&gt;-</span><span class="w"></span>
 <span class="w">      </span><span class="cp">{{</span> <span class="nv">lookup</span><span class="o">(</span><span class="s1">&#39;community.general.bitwarden&#39;</span><span class="o">,</span> <span class="s1">&#39;a_test&#39;</span><span class="o">)</span> <span class="cp">}}</span><span class="w"></span>
+
+<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="s">&quot;Get</span><span class="nv"> </span><span class="s">custom</span><span class="nv"> </span><span class="s">field</span><span class="nv"> </span><span class="s">&#39;api_key&#39;</span><span class="nv"> </span><span class="s">from</span><span class="nv"> </span><span class="s">Bitwarden</span><span class="nv"> </span><span class="s">record</span><span class="nv"> </span><span class="s">named</span><span class="nv"> </span><span class="s">&#39;a_test&#39;&quot;</span><span class="w"></span>
+<span class="w">  </span><span class="nt">ansible.builtin.debug</span><span class="p">:</span><span class="w"></span>
+<span class="w">    </span><span class="nt">msg</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">&gt;-</span><span class="w"></span>
+<span class="w">      </span><span class="cp">{{</span> <span class="nv">lookup</span><span class="o">(</span><span class="s1">&#39;community.general.bitwarden&#39;</span><span class="o">,</span> <span class="s1">&#39;a_test&#39;</span><span class="o">,</span> <span class="nv">field</span><span class="o">=</span><span class="s1">&#39;api_key&#39;</span><span class="o">)</span> <span class="cp">}}</span><span class="w"></span>
 </pre></div>
 </div>
 </section>
diff --git a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/github_release_module.html b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/github_release_module.html
index 869a423..b8eac4b 100644
--- a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/github_release_module.html
+++ b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/github_release_module.html
@@ -317,21 +317,10 @@ see <a class="reference internal" href="#ansible-collections-community-general-g
 </thead>
 <tbody>
 <tr class="row-even"><td><div class="ansible-option-cell">
-<div class="ansibleOptionAnchor" id="return-create_release"></div><p class="ansible-option-title" id="ansible-collections-community-general-github-release-module-return-create-release"><strong>create_release</strong></p>
-<a class="ansibleOptionLink" href="#return-create_release" title="Permalink to this return value"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
+<div class="ansibleOptionAnchor" id="return-tag"></div><p class="ansible-option-title" id="ansible-collections-community-general-github-release-module-return-tag"><strong>tag</strong></p>
+<a class="ansibleOptionLink" href="#return-tag" title="Permalink to this return value"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
-<td><div class="ansible-option-cell"><p>Version of the created release</p>
-<p>For Ansible version 2.5 and later, if specified release version already exists, then State is unchanged</p>
-<p>For Ansible versions prior to 2.5, if specified release version already exists, then State is skipped</p>
-<p class="ansible-option-line"><span class="ansible-option-returned-bold">Returned:</span> success</p>
-<p class="ansible-option-line ansible-option-sample"><span class="ansible-option-sample-bold">Sample:</span> <code class="ansible-option-sample docutils literal notranslate"><span class="pre">&quot;1.1.0&quot;</span></code></p>
-</div></td>
-</tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
-<div class="ansibleOptionAnchor" id="return-latest_release"></div><p class="ansible-option-title" id="ansible-collections-community-general-github-release-module-return-latest-release"><strong>latest_release</strong></p>
-<a class="ansibleOptionLink" href="#return-latest_release" title="Permalink to this return value"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
-</div></td>
-<td><div class="ansible-option-cell"><p>Version of the latest release</p>
+<td><div class="ansible-option-cell"><p>Version of the created/latest release.</p>
 <p class="ansible-option-line"><span class="ansible-option-returned-bold">Returned:</span> success</p>
 <p class="ansible-option-line ansible-option-sample"><span class="ansible-option-sample-bold">Sample:</span> <code class="ansible-option-sample docutils literal notranslate"><span class="pre">&quot;1.1.0&quot;</span></code></p>
 </div></td>
diff --git a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/manageiq_policies_module.html b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/manageiq_policies_module.html
index e44f0cf..185ca40 100644
--- a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/manageiq_policies_module.html
+++ b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/manageiq_policies_module.html
@@ -289,7 +289,7 @@ see <a class="reference internal" href="#ansible-collections-community-general-m
 </div></td>
 <td><div class="ansible-option-cell"><p><code class="docutils literal notranslate"><span class="pre">absent</span></code> - policy_profiles should not exist,</p>
 <p><code class="docutils literal notranslate"><span class="pre">present</span></code> - policy_profiles should exist,</p>
-<p><code class="docutils literal notranslate"><span class="pre">list</span></code> - list current policy_profiles and policies.</p>
+<p><code class="docutils literal notranslate"><span class="pre">list</span></code> - list current policy_profiles and policies. This state is deprecated and will be removed 8.0.0. Please use the module <a class="reference internal" href="manageiq_policies_info_module.html#ansible-collections-community-general-manageiq-policies-info-module"><span class="std std-ref">community.general.manageiq_policies_info</span></a> instead.</p>
 <p class="ansible-option-line"><span class="ansible-option-choices">Choices:</span></p>
 <ul class="simple">
 <li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">&quot;absent&quot;</span></code></p></li>
diff --git a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/sudoers_module.html b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/sudoers_module.html
index a932b51..19f4030 100644
--- a/home/runner/work/community.general/community.general/docsbuild/base/collections/community/general/sudoers_module.html
+++ b/home/runner/work/community.general/community.general/docsbuild/head/collections/community/general/sudoers_module.html
@@ -184,6 +184,15 @@
 </div></td>
 </tr>
 <tr class="row-even"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-host"></div><p class="ansible-option-title" id="ansible-collections-community-general-sudoers-module-parameter-host"><strong>host</strong></p>
+<a class="ansibleOptionLink" href="#parameter-host" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
+<p><span class="ansible-option-versionadded">added in community.general 6.2.0</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>Specify the host the rule is for.</p>
+<p class="ansible-option-line"><span class="ansible-option-default-bold">Default:</span> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;ALL&quot;</span></code></p>
+</div></td>
+</tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-name"></div><p class="ansible-option-title" id="ansible-collections-community-general-sudoers-module-parameter-name"><strong>name</strong></p>
 <a class="ansibleOptionLink" href="#parameter-name" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span> / <span class="ansible-option-required">required</span></p>
 </div></td>
@@ -191,7 +200,7 @@
 <p>This will be used for the filename for the sudoers file managed by this rule.</p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-nopassword"></div><p class="ansible-option-title" id="ansible-collections-community-general-sudoers-module-parameter-nopassword"><strong>nopassword</strong></p>
 <a class="ansibleOptionLink" href="#parameter-nopassword" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 </div></td>
@@ -203,7 +212,7 @@
 </ul>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-runas"></div><p class="ansible-option-title" id="ansible-collections-community-general-sudoers-module-parameter-runas"><strong>runas</strong></p>
 <a class="ansibleOptionLink" href="#parameter-runas" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 <p><span class="ansible-option-versionadded">added in community.general 4.7.0</span></p>
@@ -211,7 +220,7 @@
 <td><div class="ansible-option-cell"><p>Specify the target user the command(s) will run as.</p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-state"></div><p class="ansible-option-title" id="ansible-collections-community-general-sudoers-module-parameter-state"><strong>state</strong></p>
 <a class="ansibleOptionLink" href="#parameter-state" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -223,7 +232,7 @@
 </ul>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-sudoers_path"></div><p class="ansible-option-title" id="ansible-collections-community-general-sudoers-module-parameter-sudoers-path"><strong>sudoers_path</strong></p>
 <a class="ansibleOptionLink" href="#parameter-sudoers_path" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -231,7 +240,7 @@
 <p class="ansible-option-line"><span class="ansible-option-default-bold">Default:</span> <code class="ansible-option-default docutils literal notranslate"><span class="pre">&quot;/etc/sudoers.d&quot;</span></code></p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-user"></div><p class="ansible-option-title" id="ansible-collections-community-general-sudoers-module-parameter-user"><strong>user</strong></p>
 <a class="ansibleOptionLink" href="#parameter-user" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -239,7 +248,7 @@
 <p>This option cannot be used in conjunction with <em>group</em>.</p>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-validation"></div><p class="ansible-option-title" id="ansible-collections-community-general-sudoers-module-parameter-validation"><strong>validation</strong></p>
 <a class="ansibleOptionLink" href="#parameter-validation" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 <p><span class="ansible-option-versionadded">added in community.general 5.2.0</span></p>
@@ -277,10 +286,11 @@
 
 <span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">&gt;-</span><span class="w"></span>
 <span class="w">    </span><span class="no">Allow the monitoring group to run sudo /usr/local/bin/gather-app-metrics</span><span class="w"></span>
-<span class="w">    </span><span class="no">without requiring a password</span><span class="w"></span>
+<span class="w">    </span><span class="no">without requiring a password on the host called webserver</span><span class="w"></span>
 <span class="w">  </span><span class="nt">community.general.sudoers</span><span class="p">:</span><span class="w"></span>
 <span class="w">    </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">monitor-app</span><span class="w"></span>
 <span class="w">    </span><span class="nt">group</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">monitoring</span><span class="w"></span>
+<span class="w">    </span><span class="nt">host</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">webserver</span><span class="w"></span>
 <span class="w">    </span><span class="nt">commands</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">/usr/local/bin/gather-app-metrics</span><span class="w"></span>
 
 <span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">&gt;-</span><span class="w"></span>

@frzb
Copy link

frzb commented Dec 17, 2022

This is highly appreciated.
Until now the usage of Bitwarden Custom Fields requires excessive stunts with the Ansible shell module calling first bw and pipping into jq. 😕

@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-6 labels Dec 17, 2022
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! Could you please add a changelog fragment?

@@ -109,10 +114,19 @@ def get_field(self, field, search_value, search_field="name"):
"""
matches = self._get_matches(search_value, search_field)

if field:
if field in ['password', 'passwordRevisionDate', 'totp', 'uris', 'username']:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will login never contain anything else than these five fields? (If it does, this PR breaks backwards compatibility.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're very welcome. Changelog fragment has been added.

I can't answer that definitively, as I can't find the object definition in the source. However, there are no fields in the client that are not represented in my example record above, so I would imagine there are no other "login" fields at this time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, the problem is that if there are more fields, this would be a breaking change since if anyone was querying these fields successfully in the past, it won't work for them anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dug through the source a bit. I still couldn't find where it's defined on the server side, but I did find this on the official client, which seems to suggest there is one more field, autofillOnPageLoad. I have updated the PR with this additional field.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for that. I'm not a developer, just a sysadmin, so it's difficult for me to understand and navigate larger code bases. Looks like we definitively got all the login fields now.

@reverendj1
Copy link
Contributor Author

This is highly appreciated. Until now the usage of Bitwarden Custom Fields requires excessive stunts with the Ansible shell module calling first bw and pipping into jq. confused

I'm glad it will be useful to someone else!

reverendj1 and others added 2 commits December 22, 2022 10:44
We need to make sure that all login fields are accounted for, since
there will be no other way to retrieve them with this change, and we
don't want to break backwards compatibility. Looking at this code from
the official client,
https://github.com/bitwarden/clients/blob/master/libs/common/spec/models/domain/login.spec.ts,
autofillOnPageLoad might be another login field.
Clarify changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>
@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Dec 31, 2022
Fix logic. Should only error if matches were found, but are missing the custom field.

Co-authored-by: Felix Fontein <felix@fontein.de>
@ansibullbot ansibullbot removed the stale_ci CI is older than 7 days, rerun before merging label Jan 6, 2023
@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jan 7, 2023
@felixfontein felixfontein merged commit e3f02cb into ansible-collections:main Jan 7, 2023
@patchback
Copy link

patchback bot commented Jan 7, 2023

Backport to stable-6: cherry-pick succeeded

Backport PR branch: patchback/backports/stable-6/e3f02cb161b7bf351ebab9335b31056a6125348b/pr-5694

PR branch created, proceeding with making a PR.

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jan 7, 2023
* Add Support to Bitwarden Lookup for Custom Fields

This adds support to the Bitwarden lookup for retrieving values from
custom fields, such as api keys.

* Need to Return Whole Record if Field is Not Defined

* whitespace

* Add Changelog Fragment

* Need to Make Sure All Login Fields are Represented

We need to make sure that all login fields are accounted for, since
there will be no other way to retrieve them with this change, and we
don't want to break backwards compatibility. Looking at this code from
the official client,
https://github.com/bitwarden/clients/blob/master/libs/common/spec/models/domain/login.spec.ts,
autofillOnPageLoad might be another login field.

* Update changelogs/fragments/5694-add-custom-fields-to-bitwarden.yml

Clarify changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/bitwarden.py

Fix logic. Should only error if matches were found, but are missing the custom field.

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit e3f02cb)
@felixfontein
Copy link
Collaborator

@reverendj1 thanks for your contribution!
@frzb thanks for reviewing!

@patchback
Copy link

patchback bot commented Jan 7, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/e3f02cb161b7bf351ebab9335b31056a6125348b/pr-5694

Backported as #5781

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jan 7, 2023
* Add Support to Bitwarden Lookup for Custom Fields

This adds support to the Bitwarden lookup for retrieving values from
custom fields, such as api keys.

* Need to Return Whole Record if Field is Not Defined

* whitespace

* Add Changelog Fragment

* Need to Make Sure All Login Fields are Represented

We need to make sure that all login fields are accounted for, since
there will be no other way to retrieve them with this change, and we
don't want to break backwards compatibility. Looking at this code from
the official client,
https://github.com/bitwarden/clients/blob/master/libs/common/spec/models/domain/login.spec.ts,
autofillOnPageLoad might be another login field.

* Update changelogs/fragments/5694-add-custom-fields-to-bitwarden.yml

Clarify changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/bitwarden.py

Fix logic. Should only error if matches were found, but are missing the custom field.

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit e3f02cb)
felixfontein pushed a commit that referenced this pull request Jan 7, 2023
…p for Custom Fields (#5781)

Add Support to Bitwarden Lookup for Custom Fields (#5694)

* Add Support to Bitwarden Lookup for Custom Fields

This adds support to the Bitwarden lookup for retrieving values from
custom fields, such as api keys.

* Need to Return Whole Record if Field is Not Defined

* whitespace

* Add Changelog Fragment

* Need to Make Sure All Login Fields are Represented

We need to make sure that all login fields are accounted for, since
there will be no other way to retrieve them with this change, and we
don't want to break backwards compatibility. Looking at this code from
the official client,
https://github.com/bitwarden/clients/blob/master/libs/common/spec/models/domain/login.spec.ts,
autofillOnPageLoad might be another login field.

* Update changelogs/fragments/5694-add-custom-fields-to-bitwarden.yml

Clarify changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/lookup/bitwarden.py

Fix logic. Should only error if matches were found, but are missing the custom field.

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit e3f02cb)

Co-authored-by: reverendj1 <reverendj1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request lookup lookup plugin new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants