Metadata-Version: 2.4
Name: saltext.bitwarden
Version: 0.3.0
Summary: Salt Extension Modules for Bitwarden
Author-email: "Gary T. Giesen" <ggiesen@giesen.me>
License: Mozilla Public License 2.0 (MPL 2.0)
Project-URL: Homepage, https://gitlab.com/ggiesen/saltext-bitwarden
Project-URL: Documentation, https://ggiesen.gitlab.io/saltext-bitwarden
Project-URL: Source, https://gitlab.com/ggiesen/saltext-bitwarden
Project-URL: Tracker, https://gitlab.com/ggiesen/saltext-bitwarden/-/issues
Keywords: salt-extension
Platform: any
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: salt>=3006
Requires-Dist: pyhumps
Requires-Dist: requests
Provides-Extra: changelog
Requires-Dist: towncrier==25.8.0; extra == "changelog"
Provides-Extra: dev
Requires-Dist: nox[uv]>=2024.3; extra == "dev"
Requires-Dist: pre-commit>=2.21.0; extra == "dev"
Provides-Extra: dev-extra
Requires-Dist: black==26.5.1; extra == "dev-extra"
Requires-Dist: isort==8.0.1; extra == "dev-extra"
Requires-Dist: coverage>=7.6; extra == "dev-extra"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-prompt; extra == "docs"
Requires-Dist: sphinxcontrib-spelling; extra == "docs"
Requires-Dist: sphinx-copybutton; extra == "docs"
Requires-Dist: towncrier==25.8.0; extra == "docs"
Requires-Dist: sphinxcontrib-towncrier; extra == "docs"
Requires-Dist: myst_parser; extra == "docs"
Requires-Dist: furo; extra == "docs"
Requires-Dist: sphinx-inline-tabs; extra == "docs"
Provides-Extra: docsauto
Requires-Dist: sphinx-autobuild; extra == "docsauto"
Provides-Extra: lint
Requires-Dist: pylint==3.2.7; extra == "lint"
Requires-Dist: SaltPyLint; extra == "lint"
Provides-Extra: tests
Requires-Dist: pytest>=7.2.0; extra == "tests"
Requires-Dist: pytest-salt-factories>=1.0.0; sys_platform == "win32" and extra == "tests"
Requires-Dist: pytest-salt-factories[docker]>=1.0.0; sys_platform != "win32" and extra == "tests"
Requires-Dist: pytest-instafail; extra == "tests"
Requires-Dist: pytest-skip-markers>=1.5.0; extra == "tests"
Requires-Dist: pytest-subprocess; extra == "tests"
Requires-Dist: pytest-timeout; extra == "tests"
Requires-Dist: requests-mock; extra == "tests"
Dynamic: license-file

# Salt Extension for Bitwarden

Read from and write to a [Bitwarden](https://bitwarden.com/) vault from Salt: items, folders,
attachments, Sends and organization collections, through execution, runner, state and `sdb`
modules. Secrets can stay in the vault and be pulled in at render time, or the vault itself can be
managed declaratively.

```yaml
Example login:
  bitwarden.item_present:
    - name: Example Login
    - item:
        type: 1
        login:
          username: jdoe
          password: {{ salt['sdb.get']('sdb://bitwarden/by-uuid/.../password') }}
```

## Status

The [Vault Management API][vault-api] is covered for both reads and writes. The
[Public (Organization Management) API][public-api] is not yet implemented.

This extension is changing quickly, and while attempts will be made to not make breaking changes,
the current focus is on functionality rather than syntax/API stability.

Requires Python 3.10 or newer and Salt 3006 or newer.

## Design notes

**Most work goes through `bw serve`, not the CLI.** The Bitwarden CLI is a Node application, and
paying its startup cost per operation is slow enough to matter in a state run. `bw serve` exposes
the same vault over a local HTTP API, so this extension talks to that and shells out to `bw` only
for `login` and `logout`, which have no API equivalent.

**Prefer a unix socket over a TCP port.** The Vault Management API has [no authentication of its
own][bw-3932]: once the vault is unlocked, whatever can reach it can read every secret in it. On a
TCP port that is every process on the host. Binding `bw serve` to a unix socket puts access under
ordinary filesystem permissions instead. See the [configuration guide][docs-config].

**The cache is eventually consistent.** `bw serve` answers from a local cache it populates
asynchronously, so a read immediately after a write can return the old value. The states sync
before comparing, and reads retry once after a sync when an object is unexpectedly missing.

**Transient failures are retried, but never in a way that can duplicate a write.** `bw serve`
returns HTTP 400 for every failure, so retries are decided by what went wrong, not by status code.
A request that never reached `bw serve`, or that Bitwarden rate limited, is retried whatever its
method. One whose response was lost is retried only if it is a `GET`, `PUT` or `DELETE`, since a
`POST` may already have created the object. See the [troubleshooting guide][docs-troubleshooting].

## Branching

`master` is the release branch. Work happens on topic branches merged via merge request. Tags
matching `v*` enable a manual PyPI publish job.

## Security

If you discover a security vulnerability, please refer
to [Salt's security guide][security].

Note that this extension necessarily handles vault credentials. The configuration profile contains
your master password, and any node running `bw serve` holds an unlocked vault in memory. The
[configuration guide][docs-config] covers how to limit what can reach it.

## User Documentation

For setup and usage instructions, please refer to the
[User Documentation][docs].

## Contributing

The saltext-bitwarden project welcomes contributions from anyone!

The [Salt Extensions guide][salt-extensions-guide] provides comprehensive instructions on all aspects
of Salt extension development, including [writing tests][writing-tests], [running tests][running-tests],
[writing documentation][writing-docs] and [rendering the docs][rendering-docs].

### Quickstart

To get started contributing, first clone this repository (or your fork):

```bash
# Clone the repo
git clone --origin upstream git@gitlab.com:ggiesen/saltext-bitwarden.git

# Change to the repo dir
cd saltext-bitwarden
```

#### Automatic
If you have installed [direnv][direnv], copying the included `.envrc.example` to `.envrc` and
allowing it to run ensures a proper development environment is present and the virtual environment is active.

Without `direnv`, you can still run the automation explicitly:

```bash
make dev  # or python3 tools/initialize.py
source .venv/bin/activate
```

#### Manual
Please follow the [first steps][first-steps], skipping the repository initialization and first commit.

### Ways to contribute

Contributions come in many forms, and they're all valuable! Here are some ways you can help
without writing code:

* **Documentation**: Especially examples showing how to use this project
  to solve specific problems.
* **Triaging issues**: Help manage [issues][issues].

You can also contribute by:

* Writing blog posts
* Sharing your experiences using Salt + Bitwarden
  on social media
* Giving talks at conferences
* Publishing videos
* Engaging in IRC, Discord or email groups

Any of these things are super valuable to our community, and we sincerely
appreciate every contribution!

## License

This project is licensed under the Mozilla Public License 2.0. See `LICENSE` for the licence text.

Releases up to and including `0.1.0` were published under the Apache Software
License. That grant is not retracted: anyone who obtained those releases keeps
their rights under Apache 2.0. MPL 2.0 applies from the next release onwards.

Some of the packaging and tooling in this repository (`noxfile.py`,
`docs/conf.py`, the `.pre-commit-hooks/` scripts and parts of the test
scaffolding) originates from the Apache-2.0 licensed
[salt-extension-copier](https://github.com/salt-extensions/salt-extension-copier)
template. MPL 2.0 is a file-level licence and explicitly allows combining with
other terms, so those files may still carry their original licence.

[vault-api]: https://bitwarden.com/help/vault-management-api/
[public-api]: https://bitwarden.com/help/api/
[bw-3932]: https://github.com/bitwarden/clients/issues/3932
[security]: https://github.com/saltstack/salt/blob/master/SECURITY.md
[salt-extensions-guide]: https://salt-extensions.github.io/salt-extension-copier/
[writing-tests]: https://salt-extensions.github.io/salt-extension-copier/topics/testing/writing.html
[running-tests]: https://salt-extensions.github.io/salt-extension-copier/topics/testing/running.html
[writing-docs]: https://salt-extensions.github.io/salt-extension-copier/topics/documenting/writing.html
[rendering-docs]: https://salt-extensions.github.io/salt-extension-copier/topics/documenting/building.html
[first-steps]: https://salt-extensions.github.io/salt-extension-copier/topics/creation.html#initialize-the-python-virtual-environment
[direnv]: https://direnv.net
[issues]: https://gitlab.com/ggiesen/saltext-bitwarden/-/issues
[docs]: https://ggiesen.gitlab.io/saltext-bitwarden/
[docs-config]: https://ggiesen.gitlab.io/saltext-bitwarden/topics/configuration.html
[docs-troubleshooting]: https://ggiesen.gitlab.io/saltext-bitwarden/topics/troubleshooting.html
