lemmaid-cli 0.1.0__py3-none-any.whl
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.
- lemmaid_cli-0.1.0.dist-info/METADATA +96 -0
- lemmaid_cli-0.1.0.dist-info/RECORD +39 -0
- lemmaid_cli-0.1.0.dist-info/WHEEL +5 -0
- lemmaid_cli-0.1.0.dist-info/entry_points.txt +2 -0
- lemmaid_cli-0.1.0.dist-info/licenses/LICENSE +173 -0
- lemmaid_cli-0.1.0.dist-info/top_level.txt +1 -0
- scripts/__init__.py +1 -0
- scripts/auth_scope_matrix_check.py +204 -0
- scripts/backfill_agent_ops_workspace_schema.py +15 -0
- scripts/check_compat_bearer_sunset.py +71 -0
- scripts/check_trusted_issuers.py +56 -0
- scripts/compare_issuers.py +70 -0
- scripts/diag_site_admin.py +133 -0
- scripts/full_kms_migration.py +171 -0
- scripts/generate_architecture_diagram.py +694 -0
- scripts/generate_auth_scope_matrix.py +216 -0
- scripts/generate_sri_hashes.py +225 -0
- scripts/latency_budget_gate.py +140 -0
- scripts/launch_gate_smoke_ci.py +137 -0
- scripts/lemma_cli.py +5838 -0
- scripts/lemma_firewall.py +1881 -0
- scripts/proof_exchange_contract_check.py +292 -0
- scripts/redis_degrade_gate_check.py +63 -0
- scripts/reencrypt_kms_key.py +113 -0
- scripts/review_auth_scope_matrix.py +166 -0
- scripts/revoke_to_deny_evidence.py +281 -0
- scripts/run_agent_ops_pov_loops.py +278 -0
- scripts/run_agent_session_simulation.py +227 -0
- scripts/run_containment_simulation.py +406 -0
- scripts/run_firewall_integration_example.py +283 -0
- scripts/run_firewall_live_smoke.py +321 -0
- scripts/run_full_gap_test.py +264 -0
- scripts/run_full_taxonomy_demo.py +276 -0
- scripts/run_ppid_migration.py +126 -0
- scripts/run_revocation_benchmark_matrix.py +1224 -0
- scripts/run_runtime_taint_drill.py +356 -0
- scripts/run_sentry_alert_routing_drill.py +334 -0
- scripts/seed_permissions.py +127 -0
- scripts/verify_kms.py +48 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lemmaid-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lemma.id integration CLI
|
|
5
|
+
Author: Lemma.id Team
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://lemma.id
|
|
8
|
+
Project-URL: Documentation, https://lemma.id/docs/quickstart
|
|
9
|
+
Project-URL: Repository, https://github.com/JEDMckenna99/lemma-enterprise
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: requests>=2.31.0
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# lemma-cli
|
|
23
|
+
|
|
24
|
+
`lemma-cli` is the command-line interface for integrating Lemma.id authentication and running launch-grade auth checks.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pipx install lemma-cli
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## OpenClaw Starter Path
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
lemma setup-openclaw --api-base https://lemma.id --json
|
|
36
|
+
lemma safety-status --firewall-url http://127.0.0.1:8787 --json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`lemma setup-openclaw` is the public starter-safe path. It:
|
|
40
|
+
|
|
41
|
+
- opens one browser approval
|
|
42
|
+
- issues a starter-safe OpenClaw proof
|
|
43
|
+
- connects the runtime
|
|
44
|
+
- starts the local firewall
|
|
45
|
+
- verifies one protected allow
|
|
46
|
+
- kills the runtime and verifies deny
|
|
47
|
+
|
|
48
|
+
## Other Core Commands
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
lemma session start --api-base https://lemma.id
|
|
52
|
+
lemma session status --api-base https://lemma.id --json
|
|
53
|
+
lemma setup-firewall --api-base https://lemma.id --json
|
|
54
|
+
lemma setup --site-id site_demo --site-domain example.com --framework flask --json
|
|
55
|
+
lemma audit --project-dir . --framework flask --skip-health --json
|
|
56
|
+
lemma fix --project-dir . --framework flask --safe --skip-health --json
|
|
57
|
+
lemma ci --project-dir . --framework flask --skip-health --skip-smoke --json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Authentication for Sensitive Operations
|
|
61
|
+
|
|
62
|
+
Local interactive browser flow:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
lemma login --api-base https://lemma.id
|
|
66
|
+
lemma auth-status --api-base https://lemma.id --json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Headless/CI flow:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
lemma login --api-base https://lemma.id --non-interactive --platform-api-key "$LEMMA_API_KEY" --user-email "$LEMMA_ADMIN_EMAIL" --json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Sensitive Management Commands
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
lemma site-create --domain demo.example --environment development --json
|
|
79
|
+
lemma key-bootstrap --site-id site_demo --name "CI Key" --permissions read,write --json
|
|
80
|
+
lemma iam-type-create --site-id site_demo --name admin_access --iam-type role --json
|
|
81
|
+
lemma iam-type-list --site-id site_demo --json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Contract
|
|
85
|
+
|
|
86
|
+
All machine-oriented commands support `--json` and emit:
|
|
87
|
+
- `schema_version`
|
|
88
|
+
- `command`
|
|
89
|
+
- `ok`
|
|
90
|
+
- `error_code`
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
- OpenClaw Personal Quickstart: `docs/openclaw/PERSONAL_QUICKSTART.md`
|
|
95
|
+
- Quickstart: <https://lemma.id/docs/quickstart>
|
|
96
|
+
- Release checklist: `docs/operations/CLI_RELEASE_CHECKLIST.md`
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
lemmaid_cli-0.1.0.dist-info/licenses/LICENSE,sha256=scSw5Ep6ba4q3InTsv3G2cRN_9NEWUhI9jw8WtjXoxU,8977
|
|
2
|
+
scripts/__init__.py,sha256=CR-qYQrYuYaFvrmaNmV9Xuo9raJyDxxe7to7T7QCle8,46
|
|
3
|
+
scripts/auth_scope_matrix_check.py,sha256=5jKsN53HQkevPm3YjRG7RS-vopNzTTeSPC69x-_lLRM,7498
|
|
4
|
+
scripts/backfill_agent_ops_workspace_schema.py,sha256=H1QFWFkOwuKaJtMEcWPau2POhbtdIL1MbOwFL-jmYzE,342
|
|
5
|
+
scripts/check_compat_bearer_sunset.py,sha256=EABsKtWyzyopU-znZi68Cbwj59JYTEWgqiHBAAgeBxc,2230
|
|
6
|
+
scripts/check_trusted_issuers.py,sha256=RQLycZ0FTCsWM8GStlyHi0jJtzLqTDmTHLkCssgu_vE,1511
|
|
7
|
+
scripts/compare_issuers.py,sha256=oI4NSWqDHd0L_k1EDTdZyxoNqQ6nxptFkayMkBB6qKA,2188
|
|
8
|
+
scripts/diag_site_admin.py,sha256=Cjuh1NfGbdb85Ic_fEZhgUmUquAavplSYm_gUhB9R9w,3667
|
|
9
|
+
scripts/full_kms_migration.py,sha256=DirquqAa4vRIcdTmN1XNRoatRoYRVGCIpns0dvSAi2A,5973
|
|
10
|
+
scripts/generate_architecture_diagram.py,sha256=mpzWAw4GkXlCDoGPnp99xgyxECS-WqWzS2fiTkRmbDo,21816
|
|
11
|
+
scripts/generate_auth_scope_matrix.py,sha256=skWbIOTIP3zsX88zmytoAf3rXODsdg0m1vgGRzEhLEs,6783
|
|
12
|
+
scripts/generate_sri_hashes.py,sha256=wWAuZRqNFIOZWX8CU5prLyRsKvBq8-g-AFBEw81mzaQ,6711
|
|
13
|
+
scripts/latency_budget_gate.py,sha256=1Ql8Oh6OTdcMx7ttDyeDAlnRR_45jmXfGbPM1iCqeJQ,5360
|
|
14
|
+
scripts/launch_gate_smoke_ci.py,sha256=2feRR-GhLzbAHbUKPJAKzjKpwm_hdWFO-LrM00Y4Sws,5520
|
|
15
|
+
scripts/lemma_cli.py,sha256=-9m9-V0-nmHp9EoQLc3ETD94Acy59_PJBtKxYGKPVbQ,248237
|
|
16
|
+
scripts/lemma_firewall.py,sha256=J3PiDuMeJBQkp-3HLf0TVjhzkb8nyy7vEZ_YA0waBvM,76714
|
|
17
|
+
scripts/proof_exchange_contract_check.py,sha256=rSEItUXQS4D-TWdM33GC3BRZusYNKNp6MciNpPI7YBM,11551
|
|
18
|
+
scripts/redis_degrade_gate_check.py,sha256=zoTNwiln9I4K6wn6-QqV-QKNbO6xd5tG-SJFWxb1vbA,2071
|
|
19
|
+
scripts/reencrypt_kms_key.py,sha256=2xPKf8U0tO9jBu1xEcJlmKiWkDE001BAMK4pWuSWRrc,4019
|
|
20
|
+
scripts/review_auth_scope_matrix.py,sha256=Vh-OGdrhnc9Jj759UPaEdQFxumVUwYYaUaOf1rd_KSs,5441
|
|
21
|
+
scripts/revoke_to_deny_evidence.py,sha256=2foD0Wm064wCoBCYivTI4p1T2v-jUd5CuaRjbIkbQEI,10831
|
|
22
|
+
scripts/run_agent_ops_pov_loops.py,sha256=s4TxLlk2Q4t3QoTYrB9f0Wr1tmXuY7XIZE51mxbzsB4,11746
|
|
23
|
+
scripts/run_agent_session_simulation.py,sha256=q1muP_UXO_E1ObqwSpHZlvhE7vjRURzrGbeUgUn6jUU,9321
|
|
24
|
+
scripts/run_containment_simulation.py,sha256=fneLM_s-k-DT38Sc_FTUcZNEGLNFkBXUQksZMP25Q5w,15906
|
|
25
|
+
scripts/run_firewall_integration_example.py,sha256=D8Xn8c87fEquqlS9Iqnxn2zjeRnLnSJ_ofvily8Il88,10399
|
|
26
|
+
scripts/run_firewall_live_smoke.py,sha256=FwRUpgdrAfrIgVFC8nw274Jeu8UgVs3_JE8pm2SjBaU,11232
|
|
27
|
+
scripts/run_full_gap_test.py,sha256=JnlpXXuEyThC6xoV8ST_cu7d2Hb1XYmUz-EkzTrcTmU,9103
|
|
28
|
+
scripts/run_full_taxonomy_demo.py,sha256=jgH1sdJj9VFacM5H8FS1esUWV7EaBOQrJ9qH9HXrUgQ,11246
|
|
29
|
+
scripts/run_ppid_migration.py,sha256=tf9CsdDiCRdtB680LThfMwR_3iEb1L4Qu-Y_xRSv7II,5348
|
|
30
|
+
scripts/run_revocation_benchmark_matrix.py,sha256=FisG5lsI6AOTYdNdJXiQAHVT1hemVnUfWgE4QeT8Swg,48726
|
|
31
|
+
scripts/run_runtime_taint_drill.py,sha256=qk1OGoZvIrA--PS1vncDZZypgRUJSdHNbDnLYzRofYY,12715
|
|
32
|
+
scripts/run_sentry_alert_routing_drill.py,sha256=2Rknc5VAjQwr0wK9VPGq_25Ch31w9DkwD5KJpfpctMI,11081
|
|
33
|
+
scripts/seed_permissions.py,sha256=tTQqMBwR6IIWOXga_t1YOkT7eZKnKssbPp7e8o-M-nY,4661
|
|
34
|
+
scripts/verify_kms.py,sha256=CezZTdDRuZns14A-qwJAI7np_gMXdQGgOns83-OpgZs,1421
|
|
35
|
+
lemmaid_cli-0.1.0.dist-info/METADATA,sha256=wong78JB4vjNoBLOo7fEUS1w6pwNt0lJ9wYV7BFR31M,2849
|
|
36
|
+
lemmaid_cli-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
37
|
+
lemmaid_cli-0.1.0.dist-info/entry_points.txt,sha256=Kiv8XN_gSKKpL-4cggtsM3S0JGq5VWiIwjgZatLIkuA,49
|
|
38
|
+
lemmaid_cli-0.1.0.dist-info/top_level.txt,sha256=rmzd5mewlrJy4sT608KPib7sM7edoY75AeqJeY3SPB4,8
|
|
39
|
+
lemmaid_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
|
|
135
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
136
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
137
|
+
except as required for reasonable and customary use in describing the
|
|
138
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
139
|
+
|
|
140
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
141
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
142
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
143
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
144
|
+
implied, including, without limitation, any warranties or conditions
|
|
145
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
146
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
147
|
+
appropriateness of using or redistributing the Work and assume any
|
|
148
|
+
risks associated with Your exercise of permissions under this License.
|
|
149
|
+
|
|
150
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
151
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
152
|
+
unless required by applicable law (such as deliberate and grossly
|
|
153
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
154
|
+
liable to You for damages, including any direct, indirect, special,
|
|
155
|
+
incidental, or consequential damages of any character arising as a
|
|
156
|
+
result of this License or out of the use or inability to use the
|
|
157
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
158
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
159
|
+
other commercial damages or losses), even if such Contributor
|
|
160
|
+
has been advised of the possibility of such damages.
|
|
161
|
+
|
|
162
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
163
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
164
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
165
|
+
or other liability obligations and/or rights consistent with this
|
|
166
|
+
License. However, in accepting such obligations, You may act only
|
|
167
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
168
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
169
|
+
defend, and hold each Contributor harmless for any liability
|
|
170
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
171
|
+
of your accepting any such warranty or additional liability.
|
|
172
|
+
|
|
173
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
scripts
|
scripts/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Package marker for CLI entry-point imports.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Scope matrix checks for server-enforced controlled actions.
|
|
4
|
+
|
|
5
|
+
This script is intended for CI/post-deploy verification and validates:
|
|
6
|
+
- read-allowed token can access read endpoint
|
|
7
|
+
- non-admin token is forbidden on admin endpoint
|
|
8
|
+
- admin token can access admin endpoint
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
import time
|
|
17
|
+
import urllib.error
|
|
18
|
+
import urllib.request
|
|
19
|
+
import base64
|
|
20
|
+
from typing import Any
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
BASE_URL = os.environ.get("LEMMA_BASE_URL", "https://lemma.id").rstrip("/")
|
|
24
|
+
PLATFORM_API_KEY = os.environ.get("LEMMA_PLATFORM_API_KEY", "").strip()
|
|
25
|
+
EXPECT_EDGE_ADMIN_COMPAT = os.environ.get("LEMMA_EXPECT_EDGE_ADMIN_COMPAT", "").strip()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _request(
|
|
29
|
+
url: str,
|
|
30
|
+
*,
|
|
31
|
+
method: str = "GET",
|
|
32
|
+
body: dict[str, Any] | None = None,
|
|
33
|
+
headers: dict[str, str] | None = None,
|
|
34
|
+
) -> tuple[int, str]:
|
|
35
|
+
req_headers = {"User-Agent": "lemma-auth-scope-matrix/1.0"}
|
|
36
|
+
if headers:
|
|
37
|
+
req_headers.update(headers)
|
|
38
|
+
|
|
39
|
+
payload = None
|
|
40
|
+
if body is not None:
|
|
41
|
+
payload = json.dumps(body).encode("utf-8")
|
|
42
|
+
req_headers["Content-Type"] = "application/json"
|
|
43
|
+
|
|
44
|
+
req = urllib.request.Request(url=url, method=method, data=payload, headers=req_headers)
|
|
45
|
+
try:
|
|
46
|
+
with urllib.request.urlopen(req, timeout=45) as resp:
|
|
47
|
+
return resp.getcode(), resp.read().decode("utf-8", errors="replace")
|
|
48
|
+
except urllib.error.HTTPError as err:
|
|
49
|
+
return err.code, err.read().decode("utf-8", errors="replace")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _assert(condition: bool, message: str) -> None:
|
|
53
|
+
if not condition:
|
|
54
|
+
raise AssertionError(message)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _parse_json(content: str) -> dict[str, Any]:
|
|
58
|
+
if not content:
|
|
59
|
+
return {}
|
|
60
|
+
return json.loads(content)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _issue_lemma(permission_level: str, email: str) -> dict[str, Any]:
|
|
64
|
+
status, content = _request(
|
|
65
|
+
f"{BASE_URL}/api/platform/issue-site-permission",
|
|
66
|
+
method="POST",
|
|
67
|
+
body={
|
|
68
|
+
"site_id": "lemma.id",
|
|
69
|
+
"user_email": email,
|
|
70
|
+
"permission_level": permission_level,
|
|
71
|
+
"expiry_days": 7,
|
|
72
|
+
},
|
|
73
|
+
headers={"X-API-Key": PLATFORM_API_KEY},
|
|
74
|
+
)
|
|
75
|
+
_assert(status == 200, f"Expected 200 from issue-site-permission, got {status}")
|
|
76
|
+
payload = _parse_json(content)
|
|
77
|
+
_assert(payload.get("success") is True, "issue-site-permission success != true")
|
|
78
|
+
lemma = payload.get("permission_lemma")
|
|
79
|
+
_assert(isinstance(lemma, dict), "permission_lemma missing")
|
|
80
|
+
return lemma
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _encode_lemma_header(lemma: dict[str, Any]) -> str:
|
|
84
|
+
raw = json.dumps(lemma, separators=(",", ":"), sort_keys=True).encode("utf-8")
|
|
85
|
+
return base64.urlsafe_b64encode(raw).decode("utf-8").rstrip("=")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _edge_admin_headers_from_lemma(lemma: dict[str, Any]) -> dict[str, str]:
|
|
89
|
+
credential_id = str(lemma.get("id") or lemma.get("credential_id") or "").strip()
|
|
90
|
+
subject = lemma.get("credentialSubject")
|
|
91
|
+
if not isinstance(subject, dict):
|
|
92
|
+
subject = {}
|
|
93
|
+
claims = lemma.get("claims")
|
|
94
|
+
if not isinstance(claims, dict):
|
|
95
|
+
claims = {}
|
|
96
|
+
permission_id = str(
|
|
97
|
+
subject.get("permissionId")
|
|
98
|
+
or subject.get("permission_id")
|
|
99
|
+
or claims.get("permissionId")
|
|
100
|
+
or claims.get("permission_id")
|
|
101
|
+
or lemma.get("permission_id")
|
|
102
|
+
or ""
|
|
103
|
+
).strip()
|
|
104
|
+
_assert(credential_id, "lemma credential id missing for edge-admin path")
|
|
105
|
+
_assert(permission_id, "lemma permission id missing for edge-admin path")
|
|
106
|
+
return {
|
|
107
|
+
"X-Credential-ID": credential_id,
|
|
108
|
+
"X-Permission-ID": permission_id,
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _exchange(lemma: dict[str, Any]) -> str:
|
|
113
|
+
status, content = _request(
|
|
114
|
+
f"{BASE_URL}/api/auth/exchange-proof",
|
|
115
|
+
method="POST",
|
|
116
|
+
body={"credential": lemma, "site_id": "lemma.id"},
|
|
117
|
+
)
|
|
118
|
+
_assert(status == 200, f"Expected 200 from exchange-proof, got {status}")
|
|
119
|
+
payload = _parse_json(content)
|
|
120
|
+
token = payload.get("access_token", "")
|
|
121
|
+
_assert(token.startswith("lm_at_"), "exchange-proof did not return lm_at_ token")
|
|
122
|
+
return token
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def main() -> int:
|
|
126
|
+
if not PLATFORM_API_KEY:
|
|
127
|
+
raise AssertionError("LEMMA_PLATFORM_API_KEY is required for scope matrix checks")
|
|
128
|
+
|
|
129
|
+
ts = int(time.time())
|
|
130
|
+
user_email = f"scope-user-{ts}@lemma.id"
|
|
131
|
+
admin_email = f"scope-admin-{ts}@lemma.id"
|
|
132
|
+
|
|
133
|
+
user_lemma = _issue_lemma("user", user_email)
|
|
134
|
+
admin_lemma = _issue_lemma("admin", admin_email)
|
|
135
|
+
|
|
136
|
+
user_lemma_header = _encode_lemma_header(user_lemma)
|
|
137
|
+
|
|
138
|
+
# Read endpoint should work for user lemma (VC-first runtime auth)
|
|
139
|
+
status, _ = _request(
|
|
140
|
+
f"{BASE_URL}/api/billing/usage/cus_test",
|
|
141
|
+
method="GET",
|
|
142
|
+
headers={"X-Lemma-Credential": user_lemma_header},
|
|
143
|
+
)
|
|
144
|
+
print(f"user_lemma -> GET /api/billing/usage/cus_test => {status}")
|
|
145
|
+
_assert(status == 200, f"Expected 200 for user lemma on read endpoint, got {status}")
|
|
146
|
+
|
|
147
|
+
user_edge_headers = _edge_admin_headers_from_lemma(user_lemma)
|
|
148
|
+
admin_edge_headers = _edge_admin_headers_from_lemma(admin_lemma)
|
|
149
|
+
|
|
150
|
+
# Admin endpoint should reject non-admin lemma (edge-admin path headers).
|
|
151
|
+
# In production, edge compat may be disabled and return 401 auth_required.
|
|
152
|
+
status, _ = _request(
|
|
153
|
+
f"{BASE_URL}/api/admin/platform-stats",
|
|
154
|
+
method="GET",
|
|
155
|
+
headers=user_edge_headers,
|
|
156
|
+
)
|
|
157
|
+
print(f"user_edge_headers -> GET /api/admin/platform-stats => {status}")
|
|
158
|
+
if EXPECT_EDGE_ADMIN_COMPAT == "1":
|
|
159
|
+
_assert(status == 403, f"Expected 403 for user edge-admin headers on admin endpoint, got {status}")
|
|
160
|
+
elif EXPECT_EDGE_ADMIN_COMPAT == "0":
|
|
161
|
+
_assert(status == 401, f"Expected 401 when edge-admin compat is disabled, got {status}")
|
|
162
|
+
else:
|
|
163
|
+
_assert(status in {401, 403}, f"Expected 401/403 for user edge-admin headers on admin endpoint, got {status}")
|
|
164
|
+
|
|
165
|
+
# Admin endpoint should allow admin lemma (edge-admin path headers) only when compat enabled.
|
|
166
|
+
status, _ = _request(
|
|
167
|
+
f"{BASE_URL}/api/admin/platform-stats",
|
|
168
|
+
method="GET",
|
|
169
|
+
headers=admin_edge_headers,
|
|
170
|
+
)
|
|
171
|
+
print(f"admin_edge_headers -> GET /api/admin/platform-stats => {status}")
|
|
172
|
+
if EXPECT_EDGE_ADMIN_COMPAT == "1":
|
|
173
|
+
_assert(status == 200, f"Expected 200 for admin edge-admin headers on admin endpoint, got {status}")
|
|
174
|
+
elif EXPECT_EDGE_ADMIN_COMPAT == "0":
|
|
175
|
+
_assert(status == 401, f"Expected 401 when edge-admin compat is disabled, got {status}")
|
|
176
|
+
else:
|
|
177
|
+
_assert(status in {200, 401}, f"Expected 200/401 for admin edge-admin headers on admin endpoint, got {status}")
|
|
178
|
+
|
|
179
|
+
# Compatibility check: exchanged access-token behavior varies by runtime mode.
|
|
180
|
+
user_token = _exchange(user_lemma)
|
|
181
|
+
status, _ = _request(
|
|
182
|
+
f"{BASE_URL}/api/billing/usage/cus_test",
|
|
183
|
+
method="GET",
|
|
184
|
+
headers={"Authorization": f"Bearer {user_token}"},
|
|
185
|
+
)
|
|
186
|
+
print(f"user_token -> GET /api/billing/usage/cus_test => {status}")
|
|
187
|
+
|
|
188
|
+
expected_bearer_runtime = os.environ.get("LEMMA_EXPECT_BEARER_RUNTIME", "").strip()
|
|
189
|
+
if expected_bearer_runtime == "1":
|
|
190
|
+
_assert(status == 200, f"Expected 200 for user bearer token in bearer-runtime mode, got {status}")
|
|
191
|
+
elif expected_bearer_runtime == "0":
|
|
192
|
+
_assert(status == 401, f"Expected 401 for user bearer token in VC-only mode, got {status}")
|
|
193
|
+
|
|
194
|
+
print("Auth scope matrix checks passed.")
|
|
195
|
+
return 0
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
if __name__ == "__main__":
|
|
199
|
+
try:
|
|
200
|
+
raise SystemExit(main())
|
|
201
|
+
except Exception as exc:
|
|
202
|
+
print(f"Auth scope matrix checks failed: {exc}", file=sys.stderr)
|
|
203
|
+
raise SystemExit(1) from exc
|
|
204
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Backfill the workspace-first Agent Ops schema from legacy tables."""
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
from api.agent_ops_store import backfill_agent_ops_schema
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main() -> None:
|
|
10
|
+
summary = backfill_agent_ops_schema()
|
|
11
|
+
print(json.dumps({"success": True, "summary": summary}, indent=2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if __name__ == "__main__":
|
|
15
|
+
main()
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Compatibility bearer sunset gate.
|
|
4
|
+
|
|
5
|
+
Fails when compat_bearer routes remain after configured sunset date.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
from datetime import datetime, timezone
|
|
12
|
+
import os
|
|
13
|
+
import sys
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
17
|
+
from api.authz_policy import ROUTE_AUTHZ_POLICY
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _parse_iso(text: str) -> datetime:
|
|
21
|
+
parsed = datetime.fromisoformat(text.replace("Z", "+00:00"))
|
|
22
|
+
if parsed.tzinfo is None:
|
|
23
|
+
parsed = parsed.replace(tzinfo=timezone.utc)
|
|
24
|
+
return parsed.astimezone(timezone.utc)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def main() -> int:
|
|
28
|
+
parser = argparse.ArgumentParser(description="Fail when compat bearer routes remain after sunset")
|
|
29
|
+
parser.add_argument("--sunset-utc", default=os.getenv("LEMMA_COMPAT_BEARER_SUNSET_UTC", ""))
|
|
30
|
+
parser.add_argument("--allow-empty-sunset", action="store_true")
|
|
31
|
+
args = parser.parse_args()
|
|
32
|
+
|
|
33
|
+
sunset_raw = str(args.sunset_utc or "").strip()
|
|
34
|
+
if not sunset_raw:
|
|
35
|
+
if args.allow_empty_sunset:
|
|
36
|
+
print("compat sunset check: skipped (sunset not set)")
|
|
37
|
+
return 0
|
|
38
|
+
print("compat sunset check: failed (sunset not set)")
|
|
39
|
+
return 1
|
|
40
|
+
|
|
41
|
+
try:
|
|
42
|
+
sunset = _parse_iso(sunset_raw)
|
|
43
|
+
except ValueError:
|
|
44
|
+
print(f"compat sunset check: failed (invalid sunset format: {sunset_raw})")
|
|
45
|
+
return 1
|
|
46
|
+
|
|
47
|
+
now = datetime.now(timezone.utc)
|
|
48
|
+
compat_routes = [
|
|
49
|
+
f"{method} {path}"
|
|
50
|
+
for (method, path), policy in ROUTE_AUTHZ_POLICY.items()
|
|
51
|
+
if str(getattr(policy, "auth_mode", "compat_bearer") or "compat_bearer") == "compat_bearer"
|
|
52
|
+
]
|
|
53
|
+
if now >= sunset and compat_routes:
|
|
54
|
+
print(f"compat sunset check: failed (sunset passed at {sunset.isoformat()})")
|
|
55
|
+
print(f"remaining compat_bearer routes: {len(compat_routes)}")
|
|
56
|
+
for route in compat_routes[:25]:
|
|
57
|
+
print(f" - {route}")
|
|
58
|
+
if len(compat_routes) > 25:
|
|
59
|
+
print(" - ...")
|
|
60
|
+
return 1
|
|
61
|
+
|
|
62
|
+
print(
|
|
63
|
+
"compat sunset check: pass "
|
|
64
|
+
f"(now={now.isoformat()}, sunset={sunset.isoformat()}, remaining_compat={len(compat_routes)})"
|
|
65
|
+
)
|
|
66
|
+
return 0
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
raise SystemExit(main())
|
|
71
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Check trusted issuers and validate credential issuer trust
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from api.trusted_issuers import get_trusted_issuer_dids, is_trusted_issuer, clear_cache
|
|
7
|
+
|
|
8
|
+
print("=" * 60)
|
|
9
|
+
print("TRUSTED ISSUER REGISTRY")
|
|
10
|
+
print("=" * 60)
|
|
11
|
+
|
|
12
|
+
# Clear cache to get fresh data
|
|
13
|
+
clear_cache()
|
|
14
|
+
|
|
15
|
+
trusted = get_trusted_issuer_dids()
|
|
16
|
+
|
|
17
|
+
print(f"\nTotal trusted issuers: {len(trusted)}")
|
|
18
|
+
print("\nTrusted Issuer DIDs:")
|
|
19
|
+
|
|
20
|
+
for did in sorted(trusted):
|
|
21
|
+
print(f" - {did[:60]}...")
|
|
22
|
+
|
|
23
|
+
# Check some old DIDs that might be in credentials
|
|
24
|
+
print("\n" + "=" * 60)
|
|
25
|
+
print("OLD ISSUER CHECK")
|
|
26
|
+
print("=" * 60)
|
|
27
|
+
|
|
28
|
+
old_issuers = [
|
|
29
|
+
# These are the old DIDs from before KMS migration
|
|
30
|
+
"did:lemma:aba9b52a0af7966628d68f2890a899277b88f688", # Old federated
|
|
31
|
+
"did:lemma:143b960715ecaa24d02943fc0bd7b391af8f5e92", # Old lemma.id
|
|
32
|
+
"did:lemma:843982bf25189ae055c93bb381a6b3", # Old lemma_platform
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
print("\nChecking if old issuers are still trusted:")
|
|
36
|
+
for did in old_issuers:
|
|
37
|
+
is_trust = is_trusted_issuer(did)
|
|
38
|
+
status = "TRUSTED" if is_trust else "NOT TRUSTED"
|
|
39
|
+
print(f" {did[:40]}... -> {status}")
|
|
40
|
+
|
|
41
|
+
print("\n" + "=" * 60)
|
|
42
|
+
print("CURRENT ISSUER STATUS")
|
|
43
|
+
print("=" * 60)
|
|
44
|
+
|
|
45
|
+
from api.database import SessionLocal, Site
|
|
46
|
+
db = SessionLocal()
|
|
47
|
+
|
|
48
|
+
sites = db.query(Site).filter(Site.kms_encrypted_signing_key != None).all()
|
|
49
|
+
for site in sites:
|
|
50
|
+
print(f"\n{site.site_id}:")
|
|
51
|
+
print(f" DID: {site.issuer_did}")
|
|
52
|
+
print(f" Status: {site.key_status}")
|
|
53
|
+
print(f" Created: {site.key_created_at}")
|
|
54
|
+
|
|
55
|
+
db.close()
|
|
56
|
+
|