aisecuritywarden 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. aisecuritywarden-0.7.0/.github/workflows/ci.yml +46 -0
  2. aisecuritywarden-0.7.0/.github/workflows/release.yml +58 -0
  3. aisecuritywarden-0.7.0/.gitignore +13 -0
  4. aisecuritywarden-0.7.0/CLAUDE.md +52 -0
  5. aisecuritywarden-0.7.0/LICENSE +202 -0
  6. aisecuritywarden-0.7.0/PKG-INFO +276 -0
  7. aisecuritywarden-0.7.0/README.md +253 -0
  8. aisecuritywarden-0.7.0/SECURITY.md +21 -0
  9. aisecuritywarden-0.7.0/docs/DESIGN.md +992 -0
  10. aisecuritywarden-0.7.0/docs/connectors.md +15 -0
  11. aisecuritywarden-0.7.0/docs/mcp-gmail.md +174 -0
  12. aisecuritywarden-0.7.0/docs/mcp-proxy.md +125 -0
  13. aisecuritywarden-0.7.0/examples/hermes/README.md +71 -0
  14. aisecuritywarden-0.7.0/examples/hermes/securitywarden-helper.sh +24 -0
  15. aisecuritywarden-0.7.0/pyproject.toml +49 -0
  16. aisecuritywarden-0.7.0/src/securitywarden/__init__.py +7 -0
  17. aisecuritywarden-0.7.0/src/securitywarden/account.py +33 -0
  18. aisecuritywarden-0.7.0/src/securitywarden/approval.py +423 -0
  19. aisecuritywarden-0.7.0/src/securitywarden/client/__init__.py +5 -0
  20. aisecuritywarden-0.7.0/src/securitywarden/client/api.py +870 -0
  21. aisecuritywarden-0.7.0/src/securitywarden/client/cli.py +701 -0
  22. aisecuritywarden-0.7.0/src/securitywarden/client/gui.py +989 -0
  23. aisecuritywarden-0.7.0/src/securitywarden/client/origin.py +150 -0
  24. aisecuritywarden-0.7.0/src/securitywarden/client/setup.py +125 -0
  25. aisecuritywarden-0.7.0/src/securitywarden/client/tokens.py +257 -0
  26. aisecuritywarden-0.7.0/src/securitywarden/client/update.py +259 -0
  27. aisecuritywarden-0.7.0/src/securitywarden/crypto.py +894 -0
  28. aisecuritywarden-0.7.0/src/securitywarden/ipallow.py +55 -0
  29. aisecuritywarden-0.7.0/src/securitywarden/mcp/CONNECTORS.md +288 -0
  30. aisecuritywarden-0.7.0/src/securitywarden/mcp/__init__.py +25 -0
  31. aisecuritywarden-0.7.0/src/securitywarden/mcp/bundle.py +222 -0
  32. aisecuritywarden-0.7.0/src/securitywarden/mcp/catalog.py +34 -0
  33. aisecuritywarden-0.7.0/src/securitywarden/mcp/cli.py +791 -0
  34. aisecuritywarden-0.7.0/src/securitywarden/mcp/framework.py +984 -0
  35. aisecuritywarden-0.7.0/src/securitywarden/mcp/gmail.py +592 -0
  36. aisecuritywarden-0.7.0/src/securitywarden/mcp/lint.py +113 -0
  37. aisecuritywarden-0.7.0/src/securitywarden/mcp/mappings/github.swproxy +837 -0
  38. aisecuritywarden-0.7.0/src/securitywarden/mcp/proxy.py +902 -0
  39. aisecuritywarden-0.7.0/src/securitywarden/mcp/remote.py +157 -0
  40. aisecuritywarden-0.7.0/src/securitywarden/mcp/scaffold.py +284 -0
  41. aisecuritywarden-0.7.0/src/securitywarden/mcp/server.py +145 -0
  42. aisecuritywarden-0.7.0/src/securitywarden/mcp/testing.py +166 -0
  43. aisecuritywarden-0.7.0/src/securitywarden/release.py +235 -0
  44. aisecuritywarden-0.7.0/src/securitywarden/vectors.py +472 -0
  45. aisecuritywarden-0.7.0/tests/fake_upstream.py +60 -0
  46. aisecuritywarden-0.7.0/tests/test_actions.py +202 -0
  47. aisecuritywarden-0.7.0/tests/test_connector_distribution.py +248 -0
  48. aisecuritywarden-0.7.0/tests/test_connector_toolkit.py +105 -0
  49. aisecuritywarden-0.7.0/tests/test_crypto.py +109 -0
  50. aisecuritywarden-0.7.0/tests/test_gmail.py +259 -0
  51. aisecuritywarden-0.7.0/tests/test_gui_smoke.py +52 -0
  52. aisecuritywarden-0.7.0/tests/test_mcp.py +465 -0
  53. aisecuritywarden-0.7.0/tests/test_origin.py +32 -0
  54. aisecuritywarden-0.7.0/tests/test_policy.py +96 -0
  55. aisecuritywarden-0.7.0/tests/test_proxy.py +371 -0
  56. aisecuritywarden-0.7.0/tests/test_second_factor.py +90 -0
  57. aisecuritywarden-0.7.0/tests/test_setup.py +255 -0
  58. aisecuritywarden-0.7.0/tests/test_tokens.py +399 -0
  59. aisecuritywarden-0.7.0/tests/test_update.py +302 -0
  60. aisecuritywarden-0.7.0/tests/test_vectors.py +104 -0
  61. aisecuritywarden-0.7.0/tests/vectors/crypto-v1.json +1568 -0
  62. aisecuritywarden-0.7.0/tests/vectors/generate.py +7 -0
@@ -0,0 +1,46 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ["v*"]
7
+ pull_request:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ test:
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ os: [ubuntu-latest, windows-latest, macos-latest] # the client must work on Linux, Windows and macOS
18
+ python: ["3.10", "3.12", "3.13"]
19
+ runs-on: ${{ matrix.os }}
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python }}
25
+ - run: pip install -e ".[dev]"
26
+ - run: pytest -q
27
+ - name: Installed commands start, and swadmin has a usable Tk (8.6+)
28
+ shell: bash
29
+ run: |
30
+ swctl --version
31
+ sw-mcp --help > /dev/null
32
+ python -c "import tkinter, securitywarden.client.gui; assert tkinter.TkVersion >= 8.6, tkinter.TkVersion; print('Tk', tkinter.TkVersion)"
33
+
34
+ wheel:
35
+ needs: [test]
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+ - uses: actions/setup-python@v5
40
+ with:
41
+ python-version: "3.12"
42
+ - run: pip install build && python -m build
43
+ - uses: actions/upload-artifact@v4
44
+ with:
45
+ name: dist
46
+ path: dist/*
@@ -0,0 +1,58 @@
1
+ # Publishes the client to PyPI as "aisecuritywarden" when a version tag (v0.7.0, ...) is pushed.
2
+ # Uses PyPI trusted publishing: no password or token is stored anywhere. One-time setup on pypi.org:
3
+ # Your account -> Publishing -> add a (pending) publisher: project aisecuritywarden, owner SoftDevEng,
4
+ # repository aiSecurityWarden-client, workflow release.yml, environment pypi. And a "pypi" environment here
5
+ # (Settings -> Environments), optionally with required reviewers so each upload waits for a click.
6
+ # PyPI never lets a version's files be replaced: a mistake means a new version.
7
+ name: Release
8
+
9
+ on:
10
+ push:
11
+ tags: ["v*"]
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ build:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.12"
24
+ - name: The tag matches the version
25
+ run: |
26
+ v=$(python -c "import re; print(re.search(r'__version__ = \"([^\"]+)\"', open('src/securitywarden/__init__.py').read())[1])")
27
+ if [ "v$v" != "$GITHUB_REF_NAME" ]; then echo "tag $GITHUB_REF_NAME doesn't match __version__ $v"; exit 1; fi
28
+ - name: Test
29
+ run: |
30
+ python -m pip install -e ".[dev]"
31
+ python -m pytest -q
32
+ - name: Build
33
+ run: |
34
+ python -m pip install build
35
+ python -m build
36
+ ls -l dist
37
+ - name: The built wheel installs and runs
38
+ run: |
39
+ python -m venv /tmp/check
40
+ /tmp/check/bin/pip install dist/*.whl
41
+ cd /tmp && /tmp/check/bin/sw-mcp --version && /tmp/check/bin/swctl --version
42
+ - uses: actions/upload-artifact@v4
43
+ with:
44
+ name: dist
45
+ path: dist/
46
+
47
+ pypi:
48
+ needs: build
49
+ runs-on: ubuntu-latest
50
+ environment: pypi
51
+ permissions:
52
+ id-token: write # trusted publishing
53
+ steps:
54
+ - uses: actions/download-artifact@v4
55
+ with:
56
+ name: dist
57
+ path: dist/
58
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,13 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ build/
5
+ dist/
6
+ .venv/
7
+ venv/
8
+ .pytest_cache/
9
+
10
+ # never commit credentials
11
+ *.cred
12
+ token
13
+ .env
@@ -0,0 +1,52 @@
1
+ # CLAUDE.md — aiSecurityWarden client
2
+
3
+ The open-source (Apache-2.0) client for aiSecurityWarden: scoped machine tokens and end-to-end encryption.
4
+ Primary consumer: Hermes Agent via its command-helper secret source (`swctl export`).
5
+ Must run on Linux and Windows. The server is a separate, private repository (`aiSecurityWarden-server`),
6
+ which depends on this package for its crypto and parsers.
7
+
8
+ ## Layout
9
+
10
+ - `src/securitywarden/crypto.py`: **all** crypto and the credential format. Keep it the only place crypto lives
11
+ (including approval capabilities, nonces, their lookup hashes and match codes, and account key derivation).
12
+ - `src/securitywarden/approval.py`, `ipallow.py`: strict parsers for approval policies and per-token address
13
+ lists, shared with the server. `account.py`: email and password rules shared with the server and web front end.
14
+ - `src/securitywarden/client/`: `SecurityWardenClient` (`api.py`), the `swctl` CLI (`cli.py`) and the `swadmin`
15
+ Tkinter window (`gui.py`; no crypto of its own, never persists credentials).
16
+ - `src/securitywarden/vectors.py`: builds the crypto test vectors (`tests/vectors/crypto-v1.json`) every other
17
+ implementation is checked against (the server repo's browser crypto keeps a copy).
18
+ - `docs/DESIGN.md` is the source of truth for the protocol. Update it with any protocol change.
19
+
20
+ ## Commands
21
+
22
+ ```bash
23
+ pip install -e ".[dev]" && pytest -q
24
+ python -m securitywarden.vectors # after any change to crypto.py, approval.py or account.py;
25
+ # then update the copy in the server repo (tests/vectors/) and its web crypto
26
+ ```
27
+
28
+ Tests that need a running server (end-to-end, swctl, swadmin, approvals) live in the server repo, which installs
29
+ this package; run them there before releasing a change here.
30
+
31
+ ## Invariants (do not break)
32
+
33
+ 1. The client never sends a credential's `key` part, a project key, an account key, a password or a password-
34
+ derived key, or plaintext secret names/values to the server.
35
+ 2. Every ciphertext is AES-256-GCM with AAD binding it to its context (see DESIGN.md). Don't add encryption
36
+ without AAD.
37
+ 3. No custom crypto primitives. Only `cryptography` (AES-GCM, HKDF, HMAC, PBKDF2).
38
+ 4. Secret values are never accepted on the command line (argv). Use a prompt or stdin.
39
+ 5. `Credential.__repr__` must never include `secret` or `key`. Don't log credentials, JWTs or session tokens.
40
+ 6. The client refuses plain `http://` to non-local hosts unless `SW_ALLOW_HTTP=1`.
41
+ 7. Any wire/format change bumps the `sw1` / `v1.` version prefixes instead of silently changing them.
42
+ 8. `tests/vectors/crypto-v1.json` changes only by regenerating it; other implementations must then match.
43
+
44
+ ## Conventions
45
+
46
+ - Python ≥ 3.10, standard library first; keep dependencies minimal (`cryptography`, `httpx`).
47
+ - Tests for every security property you add (negative tests matter most).
48
+ - Releases are tagged `vX.Y.Z[.devN]`; the server pins a tag. A `v*` tag publishes to PyPI as `aisecuritywarden`
49
+ (`.github/workflows/release.yml`, trusted publishing); the tag must equal `__version__`. PyPI files can't be
50
+ replaced: a mistake means a new version.
51
+ - Installs as `aisecuritywarden` (PyPI), imports as `securitywarden`. User-facing text says "aiSecurityWarden". The
52
+ `securitywarden/v1/...` labels in crypto.py and the config folders never change (existing data depends on them).
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,276 @@
1
+ Metadata-Version: 2.5
2
+ Name: aisecuritywarden
3
+ Version: 0.7.0
4
+ Summary: aiSecurityWarden client: scoped, revocable machine tokens, end-to-end encrypted secrets and human approval for AI agents.
5
+ Project-URL: Homepage, https://github.com/SoftDevEng/aiSecurityWarden-client
6
+ Project-URL: Issues, https://github.com/SoftDevEng/aiSecurityWarden-client/issues
7
+ Author: SoftDevEng
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: ai-agents,aisecuritywarden,end-to-end-encryption,hermes-agent,machine-tokens,mcp,secrets,secrets-manager,vault
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Security :: Cryptography
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: cryptography>=42
19
+ Requires-Dist: httpx>=0.27
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=8; extra == 'dev'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # aiSecurityWarden client
25
+
26
+ The open-source client for **aiSecurityWarden**, a secrets service with **scoped, revocable machine tokens**
27
+ and **end-to-end encryption**. Built so AI agents (like [Hermes Agent](https://hermes-agent.nousresearch.com))
28
+ and other unattended services can fetch API keys at startup without ever storing those keys on disk.
29
+
30
+ All encryption and decryption happens here, in the client. The server only ever receives ciphertext,
31
+ proofs it keeps only as Argon2id hashes, and wrapped keys, so you can check what leaves your machine by
32
+ reading this code.
33
+
34
+ This repository contains:
35
+
36
+ - the Python client library (`securitywarden.client.SecurityWardenClient`);
37
+ - `swctl`, the command-line tool (machines: `swctl export` / `swctl run`; admins: `swctl admin ...`);
38
+ - `swadmin`, a small desktop admin window;
39
+ - the cryptography (`src/securitywarden/crypto.py`), the approval-policy and address-list parsers, and the
40
+ shared test vectors other implementations are checked against;
41
+ - the protocol and design document: [docs/DESIGN.md](docs/DESIGN.md).
42
+
43
+ The aiSecurityWarden server is a separate product.
44
+
45
+ > **Status: alpha.** The design is deliberately small and reviewable, but it has not had an independent
46
+ > security audit. Read the [threat model](#threat-model).
47
+
48
+ ## How it works
49
+
50
+ ```
51
+ Admin workstation aiSecurityWarden server Agent box (e.g. jarvis)
52
+ ───────────────── ───────────────────── ───────────────────────
53
+ swctl admin ... stores only: sw1.m.<id>.<secret>:<key>
54
+ • creates project key ───────▶ • ciphertext (chmod 600 file)
55
+ • encrypts secrets • Argon2 hashes │
56
+ • wraps project key • wrapped keys ◀── id+secret ─────┤ 1. auth → 5-min JWT
57
+ per machine token • audit log ─── ciphertext ──▶ │ 2. fetch
58
+ │ 3. decrypt locally with <key>
59
+ â–¼
60
+ KEY=VALUE → agent env → tools
61
+ ```
62
+
63
+ A machine token has three parts:
64
+
65
+ | Part | Sent to server? | Purpose |
66
+ |----------|-----------------|---------|
67
+ | `id` | yes | identifies the token |
68
+ | `secret` | yes (over TLS) | proves possession; server keeps only an Argon2id hash |
69
+ | `key` | **never** | unwraps the project key, which decrypts the secrets |
70
+
71
+ So the server can authenticate a token and hand out ciphertext, but it **cannot
72
+ read any secret**. A full copy of the server's database is useless without a token key.
73
+
74
+ ## Threat model
75
+
76
+ **Protects against**
77
+ - Secrets at rest on agent machines: only a token sits on disk, not your API keys.
78
+ Backups, copied dotfiles and logs leak a token you can revoke in one command.
79
+ - Server compromise: the database holds only AES-256-GCM ciphertext, Argon2 hashes and
80
+ wrapped keys. Ciphertext is bound to its project, token and name (AAD), so a
81
+ malicious server can't swap blobs around either.
82
+ - Over-broad access: each token is read-only and scoped to one project.
83
+ - Stale credentials: tokens can expire; revocation takes effect on the next request
84
+ (access JWTs are re-checked against the database every time).
85
+ - Brute force: Argon2id hashing, per-IP and per-token failure rate limiting, and the
86
+ same timing for unknown token ids.
87
+
88
+ **Does not protect against**
89
+ - An attacker who already controls the agent machine while it's running. They can read the
90
+ token file, or read the decrypted secrets from the process memory or environment.
91
+ No secrets manager can prevent that.
92
+ - Losing the admin credential. Project keys are wrapped under it; without it the
93
+ secrets can't be recovered (by design). Keep it in your password manager.
94
+ - A server operator who swaps in malicious *client* code. Install `swctl` from a source you trust.
95
+
96
+ ## Install
97
+
98
+ ```bash
99
+ pipx install aisecuritywarden # or: pip install aisecuritywarden (in a virtual environment)
100
+ ```
101
+
102
+ It installs the commands `swctl`, `sw-mcp` and `swadmin`. In Python code (connectors) the package is imported as
103
+ `securitywarden`, e.g. `from securitywarden.mcp import Connector`.
104
+
105
+ **Coming from 0.6 (installed as `securitywarden`)?** Reinstall once under the new name; your tokens and settings
106
+ stay where they are:
107
+
108
+ ```bash
109
+ pip uninstall securitywarden && pip install aisecuritywarden # same environment as before
110
+ ```
111
+
112
+ Needs Python 3.10+, on Linux, Windows or macOS (all three are tested in CI). `swadmin` also needs Tkinter:
113
+ it ships with the python.org installers for Windows and macOS; on Debian/Ubuntu, `sudo apt install python3-tk`.
114
+
115
+ ### macOS
116
+
117
+ 1. Install Python from [python.org](https://www.python.org/downloads/macos/) (3.10 or newer). Its installer
118
+ includes a current Tk, so `swadmin` works. Avoid Apple's built-in `/usr/bin/python3`: its Tk is old and
119
+ draws windows badly. With Homebrew's Python, also run `brew install python-tk`.
120
+ 2. Install the client in its own virtual environment:
121
+
122
+ ```bash
123
+ python3 -m venv ~/.venvs/securitywarden
124
+ ~/.venvs/securitywarden/bin/pip install aisecuritywarden
125
+ ~/.venvs/securitywarden/bin/swadmin # the admin window; swctl and sw-mcp are next to it
126
+ ```
127
+
128
+ 3. Files live where they do on Linux: `~/.config/securitywarden/` (tokens, the admin credential file if you use
129
+ one, swctl's cached 2FA session), each readable by you only.
130
+
131
+ The website works in Safari too (CI runs it in WebKit, Safari's engine).
132
+
133
+ ### Updating
134
+
135
+ ```bash
136
+ sw-mcp update --check # or: swctl update --check
137
+ sw-mcp update # installs the newest signed release; never an older one
138
+ ```
139
+
140
+ Or ask your agent: "check for aiSecurityWarden updates" / "update aiSecurityWarden". The agent's
141
+ `securitywarden_update` tool asks you to approve the exact version first. Restart the agent app afterwards. When a
142
+ newer client is out, the agent is told once (and every time if the server requires it). Updates are signed with
143
+ an offline release key and checked against the key built into the client; see DESIGN.md "Client updates".
144
+
145
+ From source:
146
+
147
+ ```bash
148
+ git clone https://github.com/SoftDevEng/aiSecurityWarden-client && cd aiSecurityWarden-client
149
+ pip install -e ".[dev]" && pytest
150
+ ```
151
+
152
+ ## Quick start
153
+
154
+ You need the address of an aiSecurityWarden server and, to administer it, its admin credential.
155
+
156
+ ### 1. Admin (from your workstation)
157
+
158
+ ```bash
159
+ mkdir -p ~/.config/securitywarden
160
+ echo 'sw1.a....' > ~/.config/securitywarden/admin.cred && chmod 600 ~/.config/securitywarden/admin.cred
161
+ export SW_SERVER_URL=https://vault.example.com
162
+
163
+ swctl admin project create hermes-webull
164
+ swctl admin secret set hermes-webull WEBULL_APP_KEY # prompts; value never in argv/history
165
+ swctl admin secret set hermes-webull WEBULL_APP_SECRET
166
+ swctl admin token create hermes-webull --name jarvis --expires-days 180
167
+ ```
168
+
169
+ ### 2. Machine
170
+
171
+ ```bash
172
+ export SW_SERVER_URL=https://vault.example.com SW_TOKEN_ID=<token id> SW_TOKEN_NAME=jarvis
173
+ swctl setup # paste the one-time setup code the website (or --setup-code) shows
174
+
175
+ swctl export # KEY=VALUE lines
176
+ swctl export --format json
177
+ swctl run -- python my_bot.py # run a command with secrets in its environment
178
+ ```
179
+
180
+ ### Hermes Agent integration
181
+
182
+ Hermes supports custom vaults through a **command helper** that prints `KEY=VALUE`
183
+ lines at launch. That's exactly what `swctl export` does. See
184
+ [examples/hermes/](examples/hermes/) for a wrapper script and config.
185
+
186
+ ### AI agent tools with approval (`sw-mcp`)
187
+
188
+ `sw-mcp` gives an agent tools for an application, such as Gmail, as an MCP server. Every action goes through
189
+ the token's rules in aiSecurityWarden: reading may be allowed outright, while sending an email waits until you
190
+ approve exactly that email (on the website, in swadmin, Telegram or ntfy). The agent is told it's waiting and
191
+ checks back. See [docs/mcp-gmail.md](docs/mcp-gmail.md) for the Gmail set-up with Hermes, and
192
+ [DESIGN.md](docs/DESIGN.md#mcp-connectors) for writing a connector for another application.
193
+
194
+ ```bash
195
+ sw-mcp tools --connector gmail # the tools, their actions, risks and suggested rules
196
+ sw-mcp serve --connector gmail # what Hermes runs (stdio)
197
+ sw-mcp call gmail_search query=is:unread limit=5 # try one tool by hand; waits for approval if needed
198
+ sw-mcp setup --token-file ~/.config/securitywarden/gmail-token # store the token from a one-time setup code
199
+ ```
200
+
201
+ Other applications get a **connector**: one Python class whose tools each declare an action and a risk. An AI can
202
+ write one: `sw-mcp new-connector NAME` creates the project (with instructions for the AI in `AGENTS.md`),
203
+ `sw-mcp guide` prints the rules, and `sw-mcp check` plus the generated tests confirm it's right. Installed
204
+ connector packages are found by name (`--connector NAME`). See [docs/connectors.md](docs/connectors.md).
205
+
206
+ Connectors can also come from aiSecurityWarden itself: turn a built-in one (Gmail) on for a project on the website,
207
+ or upload your own (`sw-mcp pack NAME`, then **Connectors > Upload**; encrypted in the browser, account-wide,
208
+ versioned with a backup of the version replaced). `sw-mcp serve` then loads whatever the token's project uses,
209
+ with no `--connector` needed, and picks up new versions as you choose: at once, or on the next restart.
210
+
211
+ ## Admin commands
212
+
213
+ | Command | |
214
+ |---|---|
215
+ | `swctl admin project create|list|delete NAME` | manage projects |
216
+ | `swctl admin secret set|get|delete PROJECT NAME` | values read from a prompt or stdin |
217
+ | `swctl admin secret list PROJECT` | names only |
218
+ | `swctl admin token create PROJECT --name N [--expires-days D] [--allow-ip ADDR]...` | prints the token once; `--allow-ip` (address or CIDR, repeatable) pins where it may connect from |
219
+ | `swctl admin token set-ips ID --allow-ip ADDR... \| --any` | replace or remove a token's allowed addresses |
220
+ | `swctl admin token list [PROJECT]` | status, expiry, last used, last IP, allowed addresses, approval |
221
+ | `swctl admin token create ... --approval session\|every_fetch [--session-ttl 8h] [--channel C]...` | require a person to approve the token's use (see below) |
222
+ | `swctl admin token set-approval ID --approval none\|session\|every_fetch [...]` | change or remove it; ends pending requests and approved sessions |
223
+ | `swctl admin token reset-approval-limits ID` | let a token that hit its hourly limit ask again now (also in swadmin: **Reset approval limit…**) |
224
+ | `swctl admin approvals list` / `approve ID [--match NN]` / `deny ID` | decide pending requests |
225
+ | `swctl admin token revoke ID` | immediate |
226
+ | `swctl admin audit [--limit N]` | auth, fetch and admin events |
227
+
228
+ ### Human approval
229
+
230
+ A machine token can require a person to approve it before it gets any secrets: once per
231
+ session (`--approval session`, the session lasts `--session-ttl`, default 8 h) or for
232
+ every fetch (`--approval every_fetch`). Requests go to the channels you choose:
233
+
234
+ - `admin_ui`: the Approvals tab in `swadmin` (or `swctl admin approvals`);
235
+ - `push:telegram` and `push:ntfy`: a phone notification with Approve / Deny buttons.
236
+ These work behind an IIS/firewall allowlist, because the server polls Telegram / ntfy
237
+ for the answer instead of the phone calling in. They are set up on the server, per project
238
+ (the project's **Approval setup** tab in the web admin).
239
+
240
+ ```bash
241
+ swctl admin token set-approval <token-id> --approval session --session-ttl 8h \
242
+ --channel admin_ui --channel push:telegram
243
+ ```
244
+
245
+ The machine prints a two-digit **match code** while it waits (`swctl: waiting for a person
246
+ to approve this session (match code 47, up to 120 s)...`); approve only if the prompt shows
247
+ the same code. An approval works once, only for the process and address that asked, and
248
+ ends when the token is revoked or its policy changes. Details: [docs/DESIGN.md](docs/DESIGN.md#human-approval).
249
+
250
+ ### Admin window (`swadmin`)
251
+
252
+ If you would rather not use a terminal, `swadmin` opens a small desktop window that does
253
+ the same things as `swctl admin`: projects, secrets, tokens (create, revoke, allowed
254
+ addresses, approval policy), pending approval requests and the activity log. The Approvals
255
+ tab checks for new requests every few seconds while you are signed in. It is installed with the client and needs only Tkinter,
256
+ which ships with Python on Windows and macOS (`sudo apt install python3-tk` on Debian/Ubuntu).
257
+
258
+ - The admin credential and secret values are pasted into the window and held in memory
259
+ only: nothing reaches argv, the environment or shell history. Only the server address is
260
+ remembered between runs.
261
+ - Encryption still happens on your machine, in the same code `swctl` uses.
262
+ - New tokens and revealed values are shown once with a Copy button; the clipboard is
263
+ cleared after a minute. The window signs out after 15 minutes without input.
264
+
265
+ ## Cryptography
266
+
267
+ All of it lives in [`src/securitywarden/crypto.py`](src/securitywarden/crypto.py): AES-256-GCM (random
268
+ 96-bit nonces) with associated data binding every ciphertext to its context, HKDF-SHA256 for key separation,
269
+ HMAC-SHA256 for secret-name lookup ids (names are encrypted too) and PBKDF2-SHA256 for account passwords,
270
+ all from the `cryptography` library. There's no custom crypto. The server stores Argon2id hashes of the
271
+ proofs clients send. Test vectors: [`tests/vectors/crypto-v1.json`](tests/vectors/crypto-v1.json)
272
+ (regenerate with `python -m securitywarden.vectors`). Full design: [docs/DESIGN.md](docs/DESIGN.md).
273
+
274
+ ## License
275
+
276
+ Apache-2.0. See [LICENSE](LICENSE). Security reports: see [SECURITY.md](SECURITY.md).