You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- interface changes will break any existing implementations
- black formatting
- add full CRUD support for secrets within a project
- add ability to access secrets fields other than values
- specify that at least one secret is required to already exist in a project
- specify and enforce that project cannot have duplicate key names
- improve organization, type hinting, and docs
- update readme
- fix passing stderr through to logging and exceptions
- update to newest CLI syntax
- other minor changes
Copy file name to clipboardExpand all lines: README.md
+74-12Lines changed: 74 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,23 +2,23 @@
2
2
This is a personal **unofficial** project. I have no affiliation with Bitwarden. Use at your own risk. Issues and feedback are welcome.
3
3
4
4
# Python wrapper for [Bitwarden Secrets Manager](https://bitwarden.com/help/secrets-manager-overview/) CLI
5
-
This module contains the `BWS` class, which is a Python wrapper for the `bws`[CLI application](https://bitwarden.com/help/secrets-manager-cli/). The class allows users to retrieve secrets stored in a Bitwarden Secrets Manager project. The module uses `subprocess` to call the `bws` CLI. The `bws` CLI application must be [downloaded separately](https://github.com/bitwarden/sdk/releases) and already present on your system (ideally in a `PATH` directory).
5
+
This module contains the `BWS` class, which is a Python wrapper for the `bws`[CLI application](https://bitwarden.com/help/secrets-manager-cli/). The `BWS`class allows users to retrieve secrets stored in a Bitwarden Secrets Manager project. The module uses `subprocess` to call the `bws` CLI. The `bws` CLI application (v.0.4.0+) must be [downloaded separately](https://github.com/bitwarden/sdk/releases) and already present on your system (ideally in a `PATH` directory).
6
6
7
-
You must also have opted-in to the Bitwarden Secrets Manager beta and have generated a project, secret(s) and service account.
7
+
You must also have a Bitwarden Secrets Manager account with an existing project, secret(s) and machine account.
- The project name as it appears in Bitwarden Secrets Manager.
29
29
- If the BWS_ACCESS_TOKEN environment variable has not been set in your environment, provide the token as a string.
30
+
- Your machine account that your access token is for must have at least `Read` access to your project (allowing get-like operations only). `Read and write` access is necessary to use functionality that adds, updates, or deletes secrets.
30
31
- By default, the class uses the `bws` or `bws.exe` application found in a `PATH` directory, but a direct path to the application can also be supplied.
32
+
-**Note: your project must already exist and contain at least one secret, otherwise initialization will fail.**
33
+
-**Another note: your project *cannot* have any duplicate key names.** Although Bitwarden Secrets Manager does support duplicate key names (and keys instead by `id`), the `BWS` class mostly abstracts the `id` field for ease of use, keying on the key name (`key`) instead. This class will not allow creation of duplicate key names when using its CRUD interfaces. Be careful not to break compatibility by adding duplicate key names via the CLI, web interface, or other tools.
31
34
32
35
Example if `bws` is not in your `PATH` and a token is not set as an environment variable:
Example if `bws` is in your `PATH` and a token is set as an environment variable:
38
-
```
41
+
```python
39
42
my_bws = BWS(project_name='my_project_name')
40
43
```
41
44
42
45
Note that each `BWS` object corresponds to a single project and service account. If you have multiple projects and/or service accounts to access, create separate `BWS` objects for each one.
43
46
44
-
## Accessing individual secrets
45
-
Access secrets from the BWS object as a key/value dictionary.
47
+
### Note on Caching Behavior
48
+
Upon initialization, all of the secrets in the given project are cached in the `BWS` instance. After initialization, get-like operations will read from the cache. Adds, updates, and deletes will update in your Bitwarden Secrets Manager account and incrementally update the cache, keeping the cache and online account in sync without unnecessary traffic. **Out-of-bound** changes to secrets made after initialization will not be reflected in the cache unless `refresh_secrets_cache()` is called on the instance.
0 commit comments