vvauth 2.0.6 → 2.1.1
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/README.md +12 -1
- package/index.js +9 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ vauth configuration file is a simple yaml file with a specific macro expansion s
|
|
|
18
18
|
The configuration file should abide the following schema
|
|
19
19
|
|
|
20
20
|
### configuration macro expansion set
|
|
21
|
-
* $${profile.XXX} expand to vault entity metadata and user `.vauth_database` vars
|
|
21
|
+
* $${profile.XXX} expand to vault entity metadata and user `.vauth_database` vars
|
|
22
22
|
* $${env.XXX} expand to local environement vars
|
|
23
23
|
* $${secrets.XXX} expand to remote scrapped secrets (see the env.paths)
|
|
24
24
|
|
|
@@ -49,3 +49,14 @@ env:
|
|
|
49
49
|
# Credits
|
|
50
50
|
* [Francois Leurent](https://github.com/131)
|
|
51
51
|
|
|
52
|
+
|
|
53
|
+
# Machine-readable environment
|
|
54
|
+
|
|
55
|
+
`vauth env --ir://json` resolves the same environment as `vauth env --source`
|
|
56
|
+
and asks the `cnyks` runner to write one JSON object to stdout. Diagnostic
|
|
57
|
+
messages remain on stderr, so a caller can parse stdout directly.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
vauth env --ir://json
|
|
61
|
+
```
|
|
62
|
+
|
package/index.js
CHANGED
|
@@ -23,7 +23,7 @@ const promiser = require('nyks/function/promiser');
|
|
|
23
23
|
const {args} = require('nyks/process/parseArgs')();
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
const {
|
|
26
|
+
const {createAgent} = require('ssh2/lib/agent');
|
|
27
27
|
const debug = require('debug');
|
|
28
28
|
|
|
29
29
|
const logger = {
|
|
@@ -48,7 +48,7 @@ class vvauth {
|
|
|
48
48
|
for(let [module_name, module_version] of Object.entries(dependencies)) {
|
|
49
49
|
|
|
50
50
|
let {version} = require(require.resolve(`${module_name}/package.json`, {
|
|
51
|
-
paths : ['.', ...require.main.paths]
|
|
51
|
+
paths : ['.', ...(require.main && require.main.paths || module.paths)]
|
|
52
52
|
}));
|
|
53
53
|
|
|
54
54
|
if(!semver.satisfies(version, module_version))
|
|
@@ -106,8 +106,9 @@ class vvauth {
|
|
|
106
106
|
async connect() {
|
|
107
107
|
let VAULT_TOKEN, {rc : {ssh_auth, jwt_auth}} = this;
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
const agent_path = process.env.SSH_AUTH_SOCK || (process.platform === 'win32' ? 'pageant' : null);
|
|
110
|
+
if(!VAULT_TOKEN && ssh_auth && agent_path)
|
|
111
|
+
VAULT_TOKEN = await this._login_vault_ssh({...ssh_auth}, agent_path);
|
|
111
112
|
|
|
112
113
|
if(!VAULT_TOKEN && jwt_auth && jwt_auth.jwt) {
|
|
113
114
|
let {path, jwt, role} = jwt_auth, payload = {jwt, role};
|
|
@@ -272,10 +273,10 @@ class vvauth {
|
|
|
272
273
|
}
|
|
273
274
|
|
|
274
275
|
|
|
275
|
-
async _login_vault_ssh({path = 'ssh', role}) {
|
|
276
|
+
async _login_vault_ssh({path = 'ssh', role}, agent_path = process.env.SSH_AUTH_SOCK) {
|
|
276
277
|
logger.info("Trying to auth as '%s'", role);
|
|
277
278
|
|
|
278
|
-
let agent =
|
|
279
|
+
let agent = createAgent(agent_path);
|
|
279
280
|
let keys = await promiser(chain => agent.getIdentities(chain));
|
|
280
281
|
|
|
281
282
|
|
|
@@ -372,7 +373,8 @@ const shellEscape = (arg) => {
|
|
|
372
373
|
//ensure module is called directly, i.e. not required
|
|
373
374
|
if(module.parent === null) {
|
|
374
375
|
let cmd = args.shift();
|
|
375
|
-
|
|
376
|
+
const output = process.argv.includes('--ir://json') ? '--ir://json' : '--ir://raw';
|
|
377
|
+
require('cnyks/lib/bundle')(vvauth, null, cmd ? [`--ir://run=${cmd}`, output] : []);
|
|
376
378
|
}
|
|
377
379
|
|
|
378
380
|
module.exports = vvauth;
|