vvauth 2.1.0 → 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/index.js +7 -6
- package/package.json +1 -1
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
|
|