lex-vault 0.1.3 → 0.2.0
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.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +7 -0
- data/.github/dependabot.yml +18 -0
- data/.github/workflows/ci.yml +19 -1
- data/.rubocop.yml +2 -53
- data/CHANGELOG.md +28 -0
- data/CLAUDE.md +35 -44
- data/Gemfile +1 -0
- data/LICENSE +201 -21
- data/README.md +82 -2
- data/lib/legion/extensions/vault/auth/helpers/login.rb +27 -0
- data/lib/legion/extensions/vault/auth/runners/app_role.rb +26 -0
- data/lib/legion/extensions/vault/auth/runners/token.rb +24 -0
- data/lib/legion/extensions/vault/auth/runners/user_pass.rb +26 -0
- data/lib/legion/extensions/vault/auth.rb +33 -0
- data/lib/legion/extensions/vault/client.rb +12 -2
- data/lib/legion/extensions/vault/errors.rb +48 -0
- data/lib/legion/extensions/vault/helpers/auth.rb +67 -0
- data/lib/legion/extensions/vault/helpers/client.rb +28 -1
- data/lib/legion/extensions/vault/runners/consul.rb +61 -0
- data/lib/legion/extensions/vault/runners/kv.rb +43 -35
- data/lib/legion/extensions/vault/runners/leases.rb +13 -12
- data/lib/legion/extensions/vault/runners/namespaces.rb +13 -12
- data/lib/legion/extensions/vault/runners/nomad.rb +72 -0
- data/lib/legion/extensions/vault/runners/pki.rb +32 -27
- data/lib/legion/extensions/vault/runners/system.rb +55 -41
- data/lib/legion/extensions/vault/runners/token.rb +37 -33
- data/lib/legion/extensions/vault/runners/transit.rb +25 -33
- data/lib/legion/extensions/vault/version.rb +1 -1
- data/lib/legion/extensions/vault.rb +31 -1
- metadata +12 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e496080f19fec686ae3a8d90aeb5abe7d785d110dd772f0da687f610a2793b86
|
|
4
|
+
data.tar.gz: 7e31745a575998a7c260dbbcf2470da8276521384c2c702af94f991905f26389
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6b467f216a25cb1f851ce7524a2ea00012786de6c17c8c1567179ddcd1bafc75f671ab23e7587194d4efcfc0cc19abc5d18e57d613aed266ef456e99bcb6794
|
|
7
|
+
data.tar.gz: 8d3dbc3ae5987461bbb3a6b7fdefcfcac7b46c9b17f1ebe9011264d81647d087d30eb9ce233c0d94f9e05ca2e53ea21b5a3bf49f4f349a98adbe0883c91ccf54
|
data/.github/CODEOWNERS
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: bundler
|
|
4
|
+
directory: /
|
|
5
|
+
schedule:
|
|
6
|
+
interval: weekly
|
|
7
|
+
day: monday
|
|
8
|
+
open-pull-requests-limit: 5
|
|
9
|
+
labels:
|
|
10
|
+
- "type:dependencies"
|
|
11
|
+
- package-ecosystem: github-actions
|
|
12
|
+
directory: /
|
|
13
|
+
schedule:
|
|
14
|
+
interval: weekly
|
|
15
|
+
day: monday
|
|
16
|
+
open-pull-requests-limit: 5
|
|
17
|
+
labels:
|
|
18
|
+
- "type:dependencies"
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -3,13 +3,31 @@ on:
|
|
|
3
3
|
push:
|
|
4
4
|
branches: [main]
|
|
5
5
|
pull_request:
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '0 9 * * 1'
|
|
6
8
|
|
|
7
9
|
jobs:
|
|
8
10
|
ci:
|
|
9
11
|
uses: LegionIO/.github/.github/workflows/ci.yml@main
|
|
10
12
|
|
|
13
|
+
excluded-files:
|
|
14
|
+
uses: LegionIO/.github/.github/workflows/excluded-files.yml@main
|
|
15
|
+
|
|
16
|
+
security:
|
|
17
|
+
uses: LegionIO/.github/.github/workflows/security-scan.yml@main
|
|
18
|
+
|
|
19
|
+
version-changelog:
|
|
20
|
+
uses: LegionIO/.github/.github/workflows/version-changelog.yml@main
|
|
21
|
+
|
|
22
|
+
dependency-review:
|
|
23
|
+
uses: LegionIO/.github/.github/workflows/dependency-review.yml@main
|
|
24
|
+
|
|
25
|
+
stale:
|
|
26
|
+
if: github.event_name == 'schedule'
|
|
27
|
+
uses: LegionIO/.github/.github/workflows/stale.yml@main
|
|
28
|
+
|
|
11
29
|
release:
|
|
12
|
-
needs: ci
|
|
30
|
+
needs: [ci, excluded-files]
|
|
13
31
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
14
32
|
uses: LegionIO/.github/.github/workflows/release.yml@main
|
|
15
33
|
secrets:
|
data/.rubocop.yml
CHANGED
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
NewCops: enable
|
|
4
|
-
SuggestExtensions: false
|
|
5
|
-
|
|
6
|
-
Layout/LineLength:
|
|
7
|
-
Max: 160
|
|
8
|
-
|
|
9
|
-
Layout/SpaceAroundEqualsInParameterDefault:
|
|
10
|
-
EnforcedStyle: space
|
|
11
|
-
|
|
12
|
-
Layout/HashAlignment:
|
|
13
|
-
EnforcedHashRocketStyle: table
|
|
14
|
-
EnforcedColonStyle: table
|
|
15
|
-
|
|
16
|
-
Metrics/MethodLength:
|
|
17
|
-
Max: 50
|
|
18
|
-
|
|
19
|
-
Metrics/ClassLength:
|
|
20
|
-
Max: 1500
|
|
21
|
-
|
|
22
|
-
Metrics/ModuleLength:
|
|
23
|
-
Max: 1500
|
|
24
|
-
|
|
25
|
-
Metrics/BlockLength:
|
|
26
|
-
Max: 40
|
|
27
|
-
Exclude:
|
|
28
|
-
- 'spec/**/*_spec.rb'
|
|
29
|
-
|
|
30
|
-
Metrics/ParameterLists:
|
|
31
|
-
Max: 8
|
|
32
|
-
|
|
33
|
-
Metrics/AbcSize:
|
|
34
|
-
Max: 60
|
|
35
|
-
|
|
36
|
-
Metrics/CyclomaticComplexity:
|
|
37
|
-
Max: 15
|
|
38
|
-
|
|
39
|
-
Metrics/PerceivedComplexity:
|
|
40
|
-
Max: 17
|
|
41
|
-
|
|
42
|
-
Style/Documentation:
|
|
43
|
-
Enabled: false
|
|
44
|
-
|
|
45
|
-
Style/SymbolArray:
|
|
46
|
-
Enabled: true
|
|
47
|
-
|
|
48
|
-
Style/FrozenStringLiteralComment:
|
|
49
|
-
Enabled: true
|
|
50
|
-
EnforcedStyle: always
|
|
51
|
-
|
|
52
|
-
Naming/FileName:
|
|
53
|
-
Enabled: false
|
|
1
|
+
inherit_gem:
|
|
2
|
+
rubocop-legion: config/lex.yml
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.0] - 2026-11-13
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `Vault::Auth` nested sub-extension: `Runners::Token#validate`, `Runners::UserPass#login` (LDAP), `Runners::AppRole#login` — auth-method token minting as first-class framework runners (own settings tree, AMQP prefix, meta-actors, MCP tools)
|
|
7
|
+
- Credential resolver (`Helpers::Auth#auth_resolve`): `token:` / `auth:` / settings precedence, single resolution point for every runner
|
|
8
|
+
- `Runners::Consul` and `Runners::Nomad` dynamic secrets engines
|
|
9
|
+
- `Errors`: `AuthUnresolved`, `APIError` (numeric code + Vault message, via the `Raiser` Faraday middleware), `ReadOnlyError`
|
|
10
|
+
- `read_only: true` guard on all write/mutating methods
|
|
11
|
+
- Ephemeral auth: `auth: { method:, ... }` opts mint a token for the call and toss it — no token state in the gem
|
|
12
|
+
|
|
13
|
+
### Changed (breaking)
|
|
14
|
+
- `remote_invocable?` is now `false` for both `Vault` and `Vault::Auth` — no meta-actors or AMQP dispatch surface. The task engine does not promise exactly-once execution; queuing secrets-engine side effects behind redelivery is a mismatch. Supported paths: in-process module calls, the standalone `Client`, MCP (synchronous). Per-runner re-enablement via `runners.<name>.remote_invocable` settings remains available.
|
|
15
|
+
- Runner return shapes: JSON bodies are returned directly with symbol keys (no `{ result: }` double-wrap); empty-body responses return `{ status: <int> }`; `Pki#ca_chain` (text PEM) wraps as `{ data: <body> }`
|
|
16
|
+
- Non-2xx Vault responses now raise `APIError` instead of returning the error body as data (`health`/`seal_status` exempt — their non-200 statuses are data)
|
|
17
|
+
- Unresolvable credentials raise `AuthUnresolved` instead of sending unauthenticated requests
|
|
18
|
+
- `KV#patch_secret` serializes the merge-patch body explicitly (Faraday's json middleware skips serialization when a non-JSON Content-Type is pre-set)
|
|
19
|
+
- Standalone `Client` seeds the resolver from constructor opts (`default_credentials` override); no longer overrides `connection`
|
|
20
|
+
- Nomad `read_role` corrected to GET `/role/{name}`; `generate_credential` corrected to POST `/cred/{accessor}` (the previous implementation never actually minted credentials)
|
|
21
|
+
|
|
22
|
+
### Notes
|
|
23
|
+
- Credentials are not yet redacted from logs/exception context — time-boxed to the end-to-end validation phase, tracked as the next follow-up
|
|
24
|
+
- The standalone `Client` does not mix in the dynamic engines or auth runners (shared method names would shadow); standalone auth uses the `auth:` descriptor
|
|
25
|
+
|
|
26
|
+
## [0.1.4] - 2026-03-30
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- update to rubocop-legion 0.1.7, resolve all offenses
|
|
30
|
+
|
|
3
31
|
## [0.1.3] - 2026-03-22
|
|
4
32
|
|
|
5
33
|
### Changed
|
data/CLAUDE.md
CHANGED
|
@@ -1,53 +1,44 @@
|
|
|
1
|
-
# lex-vault
|
|
1
|
+
# lex-vault
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
- **Parent (Level 2)**: `/Users/miverso2/rubymine/legion/extensions/CLAUDE.md`
|
|
5
|
-
- **Parent (Level 1)**: `/Users/miverso2/rubymine/legion/CLAUDE.md`
|
|
6
|
-
|
|
7
|
-
## Purpose
|
|
8
|
-
|
|
9
|
-
Legion Extension that connects LegionIO to HashiCorp Vault. Provides runners for system operations, KV v2 secrets, token auth, Transit encryption, PKI certificates, and lease management.
|
|
10
|
-
|
|
11
|
-
**GitHub**: https://github.com/LegionIO/lex-vault
|
|
12
|
-
**License**: MIT
|
|
13
|
-
**Version**: 0.1.1
|
|
3
|
+
Legion Extension connecting LegionIO to HashiCorp Vault. Provides runners for system operations, KV v2 secrets, token auth management, Transit encryption, PKI certificates, lease management, dynamic secrets (Consul, Nomad), Enterprise namespace management, and auth-method token minting (LDAP, AppRole).
|
|
14
4
|
|
|
15
5
|
## Architecture
|
|
16
6
|
|
|
17
7
|
```
|
|
18
8
|
Legion::Extensions::Vault
|
|
19
|
-
├──
|
|
20
|
-
│ ├── System # Health, seal/unseal, mounts, auth, policies
|
|
21
|
-
│ ├── Kv # KV v2: read/write/delete/list secrets + metadata
|
|
22
|
-
│ ├── Token # Token auth: create/lookup/renew/revoke + roles
|
|
23
|
-
│ ├── Transit # Encrypt/decrypt/sign/verify/hash/random
|
|
24
|
-
│ ├── Pki # Issue/sign/revoke certs, CA chain, roles
|
|
25
|
-
│ └── Leases # Lookup/renew/revoke leases
|
|
9
|
+
├── Errors/ # AuthUnresolved, APIError (code+message), ReadOnlyError, Raiser (Faraday middleware)
|
|
26
10
|
├── Helpers/
|
|
27
|
-
│
|
|
28
|
-
└──
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
bundle install
|
|
47
|
-
bundle exec rspec
|
|
48
|
-
bundle exec rubocop
|
|
11
|
+
│ ├── Client # build_connection (Faraday) + connection (pipe entry) + vault_normalize
|
|
12
|
+
│ └── Auth # auth_resolve — the credential resolver (opts pipe policy)
|
|
13
|
+
├── Runners/ # engines, flat
|
|
14
|
+
│ ├── System # health/seal-status (Raiser bypass: non-200 is data), seal/unseal, mounts, auth, policies
|
|
15
|
+
│ ├── Kv # KV v2: read/write/patch/delete secrets + versions + metadata
|
|
16
|
+
│ ├── Token # token auth engine management: create/lookup/renew/revoke + roles
|
|
17
|
+
│ ├── Transit # encrypt/decrypt/rewrap/datakey/sign/verify/hash/random + keys
|
|
18
|
+
│ ├── Pki # issue/sign/revoke certs, CA chain (text → { data: }), roles, tidy
|
|
19
|
+
│ ├── Leases # lookup/renew/revoke leases
|
|
20
|
+
│ ├── Namespaces # Vault Enterprise namespace CRUD
|
|
21
|
+
│ ├── Consul # dynamic secrets: config/access, role CRUD, generate_credential
|
|
22
|
+
│ └── Nomad # dynamic secrets: config access/lease, role CRUD, POST /cred/{accessor}
|
|
23
|
+
├── Auth/ # nested sub-extension (own settings tree; not remotely invocable)
|
|
24
|
+
│ ├── Helpers/Login # vault_login — shared mint (never attaches a token)
|
|
25
|
+
│ └── Runners/
|
|
26
|
+
│ ├── Token # validate (lookup) — not a mint
|
|
27
|
+
│ ├── UserPass # LDAP login
|
|
28
|
+
│ └── AppRole # AppRole login
|
|
29
|
+
└── Client # standalone client (core engines only; auth via the auth: descriptor)
|
|
49
30
|
```
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
**
|
|
32
|
+
## Key Design Decisions
|
|
33
|
+
|
|
34
|
+
- **The opts pipe.** Credential opts (`token:`, `address:`, `namespace:`, `auth: { method:, ... }`) flow through every runner's trailing `**` and are resolved in exactly one place: `Helpers::Auth#auth_resolve`. Precedence: explicit `token:` > `auth:` descriptor > settings (`extensions.vault`). Runners never touch credential keys; `connection(**)` is the only pipe entry.
|
|
35
|
+
- **Ephemeral minting.** An `auth:` descriptor mints a token via the matching `Vault::Auth` runner (direct module call, not through the tasker), uses it for the call, and tosses it. No token state, caching, or renewal lives in this gem — node-identity token lifecycle is legion-crypt's job.
|
|
36
|
+
- **Fail loud, named.** No resolvable credentials → `AuthUnresolved`; non-2xx Vault responses → `APIError` (via the `Raiser` Faraday middleware); write with `read_only: true` → `ReadOnlyError`. A raised named error is the framework's known-outcome path (`task.exception`) — runner code has no rescue blocks.
|
|
37
|
+
- **Returns.** JSON-body responses return the normalized body directly (symbol keys via `vault_normalize`); empty-body (204) responses return `{ status: <int> }`; the plain-text PEM endpoint (`Pki#ca_chain`) wraps as `{ data: <body> }`. No `{ result: }` double-wrap.
|
|
38
|
+
- **health/seal-status bypass the Raiser** (`raise_errors: false`) — their non-200 statuses (sealed, standby, uninit) are data.
|
|
39
|
+
- **Client is core engines only.** The dynamic engines (Consul/Nomad) and auth runners are NOT mixed into `Client` — they share generic method names (`create_role`, `login`, ...) that would shadow each other. Standalone auth: `Client.new(auth: { method: :user_pass, username:, password: })`.
|
|
40
|
+
- **Not remotely invocable.** Both `Vault` and `Vault::Auth` declare `remote_invocable? → false`: no meta-actors, no AMQP dispatch surface. Rationale: the task engine does not promise exactly-once execution; queuing secrets-engine side effects behind redelivery is a mismatch, and Vault calls are fast synchronous HTTP. In-process module calls, the standalone `Client`, and MCP (synchronous) are the supported paths. `transport_required?` in `Core` is a dead flag (defined, never consumed) — do not use it.
|
|
41
|
+
- **Consul's business token is `consul_token:`** — never the pipe's `token:` (that's the Vault credential).
|
|
42
|
+
- **Nomad corrections vs. the original internal implementation:** `read_role` is GET `/role/{name}` (was POST); `generate_credential` is POST `/cred/{accessor}` (was GET of the role path — it never minted).
|
|
43
|
+
- Depends on `faraday`. All API calls go through `/v1/`.
|
|
44
|
+
- Known limitation (time-boxed): credentials are NOT redacted from logs/exception context yet — plain text until end-to-end validation with a daemon is complete. Tracked as the next follow-up.
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
|
@@ -1,21 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2021 Esity
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# lex-vault
|
|
2
2
|
|
|
3
|
-
HashiCorp Vault integration for [LegionIO](https://github.com/LegionIO/LegionIO). Provides runners for
|
|
3
|
+
HashiCorp Vault integration for [LegionIO](https://github.com/LegionIO/LegionIO). Provides runners for the Vault HTTP API: system operations, KV v2 secrets, token auth management, Transit encryption, PKI certificates, lease management, dynamic secrets engines (Consul, Nomad), Enterprise namespaces, and auth-method token minting (LDAP, AppRole).
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,15 +8,37 @@ HashiCorp Vault integration for [LegionIO](https://github.com/LegionIO/LegionIO)
|
|
|
8
8
|
gem install lex-vault
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Credentials
|
|
12
|
+
|
|
13
|
+
Every runner method accepts the same optional credential opts (they flow through the
|
|
14
|
+
method's trailing `**` and are resolved in one place):
|
|
15
|
+
|
|
16
|
+
| Opt | Meaning |
|
|
17
|
+
|-----|---------|
|
|
18
|
+
| `token:` | Use this Vault token for the call. |
|
|
19
|
+
| `address:` | Vault base URL (overrides the configured address). |
|
|
20
|
+
| `namespace:` | Enterprise namespace for the call. |
|
|
21
|
+
| `auth:` | `{ method: :user_pass, username:, password: }` or `{ method: :app_role, role_id:, secret_id: }` — mints a token for this call (ephemeral: used once, tossed). |
|
|
22
|
+
|
|
23
|
+
Precedence: `token:` > `auth:` > configured settings
|
|
24
|
+
(`Legion::Settings[:extensions][:vault]`: `address`, `token`, `namespace`).
|
|
25
|
+
No resolvable credentials raise `Legion::Extensions::Vault::Errors::AuthUnresolved`.
|
|
26
|
+
|
|
27
|
+
Non-2xx Vault responses raise `Legion::Extensions::Vault::Errors::APIError`
|
|
28
|
+
(carries the numeric `code` and Vault's message). Write methods accept
|
|
29
|
+
`read_only: true`, which raises `ReadOnlyError` instead of executing.
|
|
30
|
+
|
|
11
31
|
## Functions
|
|
12
32
|
|
|
13
33
|
### System
|
|
14
34
|
`health`, `seal_status`, `seal`, `unseal`, `init`, `list_mounts`, `mount`, `unmount`, `list_auth`, `enable_auth`, `disable_auth`, `list_policies`, `get_policy`, `put_policy`, `delete_policy`
|
|
15
35
|
|
|
36
|
+
(`health`/`seal_status` return their non-200 statuses as data — sealed/standby/uninitialized are conditions, not errors.)
|
|
37
|
+
|
|
16
38
|
### KV (v2 Secrets)
|
|
17
39
|
`read_secret`, `write_secret`, `patch_secret`, `delete_secret`, `delete_versions`, `undelete_versions`, `destroy_versions`, `list_secrets`, `read_metadata`, `write_metadata`, `delete_metadata`
|
|
18
40
|
|
|
19
|
-
### Token
|
|
41
|
+
### Token (auth engine management)
|
|
20
42
|
`create_token`, `lookup_token`, `lookup_self`, `renew_token`, `renew_self`, `revoke_token`, `revoke_self`, `list_accessors`, `list_token_roles`, `get_token_role`, `create_token_role`, `delete_token_role`
|
|
21
43
|
|
|
22
44
|
### Transit
|
|
@@ -28,6 +50,48 @@ gem install lex-vault
|
|
|
28
50
|
### Leases
|
|
29
51
|
`lookup_lease`, `renew_lease`, `revoke_lease`, `list_leases`
|
|
30
52
|
|
|
53
|
+
### Namespaces (Vault Enterprise)
|
|
54
|
+
`list_namespaces`, `get_namespace`, `create_namespace`, `delete_namespace`
|
|
55
|
+
|
|
56
|
+
### Consul (dynamic secrets)
|
|
57
|
+
`configure` (the Consul server's own token is `consul_token:`, not the Vault `token:`), `create_role`, `read_role`, `list_roles`, `delete_role`, `generate_credential`
|
|
58
|
+
|
|
59
|
+
### Nomad (dynamic secrets)
|
|
60
|
+
`create_role`, `read_role`, `list_roles`, `delete_role`, `generate_credential(accessor:)` (POST `/v1/nomad/cred/{accessor}`), `configure_access`, `read_config_access`, `configure_lease`, `read_lease`, `delete_lease`
|
|
61
|
+
|
|
62
|
+
### Auth (token minting)
|
|
63
|
+
`validate(token:)` — look up a token's properties. `login(username:, password:, mount: 'ldap')` — LDAP. `login(role_id:, secret_id:, mount: 'approle')` — AppRole. All return Vault's standard login envelope (`auth: { client_token:, lease_id:, ... }`).
|
|
64
|
+
|
|
65
|
+
## Returns
|
|
66
|
+
|
|
67
|
+
- JSON-body responses: the normalized body, **symbol keys**, no wrapping
|
|
68
|
+
(`read_secret` → `{ data: { data: {...}, metadata: {...} } }`).
|
|
69
|
+
- Empty-body (204) responses: `{ status: 204 }`.
|
|
70
|
+
- `Pki#ca_chain` (plain-text PEM): `{ data: "-----BEGIN CERTIFICATE-----..." }`.
|
|
71
|
+
|
|
72
|
+
## Framework Usage
|
|
73
|
+
|
|
74
|
+
lex-vault is **not remotely invocable** — no AMQP/meta-actor dispatch surface. The
|
|
75
|
+
task engine does not promise exactly-once execution, and queuing secrets-engine side
|
|
76
|
+
effects (unseal, policy writes, revokes) behind redelivery is a mismatch. Call the
|
|
77
|
+
runners in-process:
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
# Credentials from settings (extensions.vault) or call-time opts
|
|
81
|
+
Legion::Extensions::Vault::Runners::Kv.read_secret(path: 'myapp/config',
|
|
82
|
+
token: 'hvs.your-token')
|
|
83
|
+
|
|
84
|
+
# Mint via LDAP for a single call (ephemeral)
|
|
85
|
+
Legion::Extensions::Vault::Runners::Kv.read_secret(path: 'myapp/config',
|
|
86
|
+
auth: { method: :user_pass,
|
|
87
|
+
username: 'svc',
|
|
88
|
+
password: '...' })
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The MCP tool surface is unaffected (synchronous agent calls). Per-runner remote
|
|
92
|
+
invocability can still be re-enabled later via settings
|
|
93
|
+
(`runners.<name>.remote_invocable`) if a use case earns it.
|
|
94
|
+
|
|
31
95
|
## Standalone Usage
|
|
32
96
|
|
|
33
97
|
```ruby
|
|
@@ -50,8 +114,24 @@ client.encrypt(name: 'my-key', plaintext: Base64.strict_encode64('hello'))
|
|
|
50
114
|
|
|
51
115
|
# Issue a PKI certificate
|
|
52
116
|
client.issue(role: 'web-server', common_name: 'app.example.com')
|
|
117
|
+
|
|
118
|
+
# Or mint via the descriptor instead of holding a token
|
|
119
|
+
client = Legion::Extensions::Vault::Client.new(
|
|
120
|
+
address: 'https://vault.example.com',
|
|
121
|
+
auth: { method: :app_role, role_id: 'r.id', secret_id: 's.id' }
|
|
122
|
+
)
|
|
53
123
|
```
|
|
54
124
|
|
|
125
|
+
The standalone `Client` covers the core engines. The dynamic engines (Consul/Nomad)
|
|
126
|
+
and auth runners are framework-level units — they share generic method names
|
|
127
|
+
(`create_role`, `login`) that would shadow each other in one class.
|
|
128
|
+
|
|
129
|
+
## Known limitation (time-boxed)
|
|
130
|
+
|
|
131
|
+
Credentials are not yet redacted from logs and exception context — they appear in
|
|
132
|
+
plain text. This is intentional during the end-to-end validation phase and is the
|
|
133
|
+
tracked follow-up for the next release.
|
|
134
|
+
|
|
55
135
|
## Requirements
|
|
56
136
|
|
|
57
137
|
- Ruby >= 3.4
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/vault/helpers/client'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Vault
|
|
8
|
+
module Auth
|
|
9
|
+
module Helpers
|
|
10
|
+
module Login
|
|
11
|
+
include Legion::Extensions::Vault::Helpers::Client
|
|
12
|
+
|
|
13
|
+
# Shared login for the mint-based auth methods. Bypasses
|
|
14
|
+
# auth_resolve on purpose: a login call must not re-enter
|
|
15
|
+
# resolution, and it never carries a token — that's what we're
|
|
16
|
+
# minting. Returns the raw parsed body; the runner normalizes.
|
|
17
|
+
def vault_login(mount:, body:, **opts)
|
|
18
|
+
base = default_credentials.merge(opts.compact)
|
|
19
|
+
build_connection(address: base[:address], namespace: base[:namespace])
|
|
20
|
+
.post("/v1/auth/#{mount}/login", body).body
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|