Fix bug dc token env (#1350)

* Add Boundary password as env variable. WIP

* Add Boundary password as env variable to the spawn process

* fix: 🐛 Fix token flag when connecting a target

Fix a token flag when connecting to a target. Now it uses an env
variable

* Add rest env variables to child processes

Co-authored-by: Carlos Alcaide Corvo <ccorvo@hashicorp.com>
This commit is contained in:
Zhihe LiandCarlos Alcaide Corvo authored and GitHub committed 2022-09-26 12:39:49 -04:00
1 parent e2fff61416
commit 4c4d4e2351
2 files changed
+18 -11

No files matched your search

@@ -25,9 +25,14 @@ module.exports = {
* @param {string} command
* @return {Promise}
*/
spawnAsyncJSONPromise(command) {
spawnAsyncJSONPromise(command, token) {
return new Promise((resolve, reject) => {
const childProcess = spawn(path(), command);
const childProcess = spawn(path(), command, {
env: {
...process.env,
BOUNDARY_TOKEN: token
}
});
let outputStream = '';
let errorStream = '';
+11 -9
View File
@@ -48,13 +48,16 @@ class Session {
*/
start() {
const command = this.cliCommand();
return spawnAsyncJSONPromise(command).then((spawnedSession) => {
this.#process = spawnedSession.childProcess;
this.#proxyDetails = spawnedSession.response;
this.#process = spawnedSession.childProcess;
this.#id = this.#proxyDetails.session_id;
return this.#proxyDetails;
});
const sanitizedToken = sanitizer.base62EscapeAndValidate(this.#token);
return spawnAsyncJSONPromise(command, sanitizedToken).then(
(spawnedSession) => {
this.#process = spawnedSession.childProcess;
this.#proxyDetails = spawnedSession.response;
this.#process = spawnedSession.childProcess;
this.#id = this.#proxyDetails.session_id;
return this.#proxyDetails;
}
);
}
/**
@@ -87,14 +90,13 @@ class Session {
cliCommand() {
const sanitized = {
target_id: sanitizer.base62EscapeAndValidate(this.#targetId),
token: sanitizer.base62EscapeAndValidate(this.#token),
addr: sanitizer.urlValidate(this.#addr),
};
const command = [
'connect',
`-target-id=${sanitized.target_id}`,
`-token=${sanitized.token}`,
`-token=env://BOUNDARY_TOKEN`,
`-addr=${sanitized.addr}`,
'-format=json',
];