vvauth 2.8.1 → 2.8.2
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.
- package/API_and_tests.md +3 -1
- package/go.mod +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/test/env-source.js +26 -0
- package/vauth.go +2 -1
package/API_and_tests.md
CHANGED
|
@@ -72,7 +72,9 @@ Commands are `env`, `login`, `show`, `set`, `unset`, `dotenv`, `install`, `versi
|
|
|
72
72
|
and `gitlab`. `set KEY VALUE` / `unset KEY` also accept `--k` / `--v`. Boolean
|
|
73
73
|
flags accept true, false, 0 and empty forms. `env` supports source, renew and
|
|
74
74
|
gitlab and ping flags; `login` supports source and renew. Hidden `connect` remains
|
|
75
|
-
available for token-only callers.
|
|
75
|
+
available for token-only callers. `login --source` exports only `VAULT_TOKEN`
|
|
76
|
+
and the resolved `VAULT_ADDR`, without fetching profile data, resolving mapped
|
|
77
|
+
secrets, or issuing delegated tokens. No command runner is part of this API.
|
|
76
78
|
|
|
77
79
|
Objects are JSON, strings are raw without JSON mode, and version is one line.
|
|
78
80
|
Exit is zero on success and one on failure; errors go to stderr.
|
package/go.mod
CHANGED
package/index.js
CHANGED
|
@@ -88,7 +88,7 @@ class Vvauth extends VauthLogin {
|
|
|
88
88
|
*/ {
|
|
89
89
|
await this.Connect(renew);
|
|
90
90
|
if(source) {
|
|
91
|
-
let env = {VAULT_TOKEN : this.VAULT_TOKEN || ''};
|
|
91
|
+
let env = {VAULT_TOKEN : this.VAULT_TOKEN || '', VAULT_ADDR : this.VAULT_ADDR || ''};
|
|
92
92
|
this.PublishEnv(env);
|
|
93
93
|
}
|
|
94
94
|
}
|
package/package.json
CHANGED
package/test/env-source.js
CHANGED
|
@@ -142,6 +142,32 @@ printf '%s|continued|%s|%s|%s|%s\\n' "$status" "$OK" "$COUNT" "$FLAG" "$EMPTY"
|
|
|
142
142
|
assert.equal(shell.stdout, `0|continued|${values.OK}|42|false|\n`);
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
+
test('login --source exports only the resolved Vault session', async t => {
|
|
146
|
+
const requests = [];
|
|
147
|
+
const f = await fixture(t, {
|
|
148
|
+
jwt_auth : {role : 'synthetic-role', jwt : 'synthetic-jwt'},
|
|
149
|
+
delegate : ['router'],
|
|
150
|
+
env : {paths : ['synthetic-path'], map : {ROUTER : '$${delegate.router}'}},
|
|
151
|
+
}, (req, res) => {
|
|
152
|
+
requests.push(req.url);
|
|
153
|
+
if(req.url === '/v1/auth/jwt/login') {
|
|
154
|
+
res.end('{"auth":{"client_token":"synthetic-issued","lease_duration":3600,"renewable":false}}');
|
|
155
|
+
} else {
|
|
156
|
+
res.writeHead(403);
|
|
157
|
+
res.end('{}');
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
const address = f.env.VAULT_ADDR;
|
|
161
|
+
delete f.env.VAULT_ADDR;
|
|
162
|
+
const result = await f.cli('login', '--source');
|
|
163
|
+
assert.equal(result.code, 0);
|
|
164
|
+
assert.deepEqual(result.stdout.match(/^export .*$/gm), [
|
|
165
|
+
"export VAULT_TOKEN='synthetic-issued'", `export VAULT_ADDR='${address}'`,
|
|
166
|
+
]);
|
|
167
|
+
assert.doesNotMatch(result.stderr, /synthetic-issued/);
|
|
168
|
+
assert.deepEqual(requests, ['/v1/auth/jwt/login']);
|
|
169
|
+
});
|
|
170
|
+
|
|
145
171
|
test('renew flag still forces login instead of the inherited token', async t => {
|
|
146
172
|
let logins = 0;
|
|
147
173
|
const f = await fixture(t, {jwt_auth : {role : 'synthetic-role', jwt : 'synthetic-jwt'}}, (req, res) => {
|
package/vauth.go
CHANGED
|
@@ -368,7 +368,7 @@ func (v *Vauth) Env(renew bool) (*OrderedMap, error) {
|
|
|
368
368
|
// .vauthrc may come from an untrusted working directory.
|
|
369
369
|
var envName = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_]*$`)
|
|
370
370
|
|
|
371
|
-
// Login connects
|
|
371
|
+
// Login connects without loading the Vault environment and optionally exports its credentials.
|
|
372
372
|
func (v *Vauth) Login(source, renew bool) error {
|
|
373
373
|
if _, err := v.Connect(renew); err != nil {
|
|
374
374
|
return err
|
|
@@ -376,6 +376,7 @@ func (v *Vauth) Login(source, renew bool) error {
|
|
|
376
376
|
if source {
|
|
377
377
|
env := &OrderedMap{}
|
|
378
378
|
env.Set("VAULT_TOKEN", v.VAULT_TOKEN())
|
|
379
|
+
env.Set("VAULT_ADDR", v.VAULT_ADDR())
|
|
379
380
|
v.PublishEnv(env)
|
|
380
381
|
}
|
|
381
382
|
return nil
|