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 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. No command runner is part of this API.
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
@@ -1,6 +1,6 @@
1
1
  module github.com/131/vvauth/v2
2
2
 
3
- // version: 2.8.1
3
+ // version: 2.8.2
4
4
 
5
5
  go 1.22
6
6
 
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vvauth",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "description": "Vault Auth helper",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -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, and with source publishes VAULT_TOKEN as shell exports.
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