From fd8d358b632ce344ab2b3b173eb34022fc729392 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 14 Jul 2019 18:55:12 -0400 Subject: [PATCH] fix: git private key alt paste mode --- client/components/admin/admin-analytics.vue | 12 ++++ client/components/admin/admin-auth.vue | 12 ++++ client/components/admin/admin-search.vue | 12 ++++ client/components/admin/admin-storage.vue | 12 ++++ server/helpers/common.js | 1 + .../authentication/saml/definition.yml | 3 + server/modules/storage/git/definition.yml | 57 ++++++++++++------- server/modules/storage/git/storage.js | 12 ++++ 8 files changed, 101 insertions(+), 20 deletions(-) diff --git a/client/components/admin/admin-analytics.vue b/client/components/admin/admin-analytics.vue index 800e5ed3..09281c11 100644 --- a/client/components/admin/admin-analytics.vue +++ b/client/components/admin/admin-analytics.vue @@ -70,6 +70,18 @@ :hint='cfg.value.hint ? cfg.value.hint : ""' persistent-hint ) + v-textarea( + v-else-if='cfg.value.type === "string" && cfg.value.multiline' + outline + background-color='grey lighten-2' + :key='cfg.key' + :label='cfg.value.title' + v-model='cfg.value.value' + prepend-icon='settings_applications' + :hint='cfg.value.hint ? cfg.value.hint : ""' + persistent-hint + :class='cfg.value.hint ? "mb-2" : ""' + ) v-text-field( v-else outline diff --git a/client/components/admin/admin-auth.vue b/client/components/admin/admin-auth.vue index c9b1b347..e5cd22c1 100644 --- a/client/components/admin/admin-auth.vue +++ b/client/components/admin/admin-auth.vue @@ -106,6 +106,18 @@ :hint='cfg.value.hint ? cfg.value.hint : ""' persistent-hint ) + v-textarea( + v-else-if='cfg.value.type === "string" && cfg.value.multiline' + outline + background-color='grey lighten-2' + :key='cfg.key' + :label='cfg.value.title' + v-model='cfg.value.value' + prepend-icon='settings_applications' + :hint='cfg.value.hint ? cfg.value.hint : ""' + persistent-hint + :class='cfg.value.hint ? "mb-2" : ""' + ) v-text-field( v-else outline diff --git a/client/components/admin/admin-search.vue b/client/components/admin/admin-search.vue index a34a73f3..7d9864f5 100644 --- a/client/components/admin/admin-search.vue +++ b/client/components/admin/admin-search.vue @@ -71,6 +71,18 @@ :hint='cfg.value.hint ? cfg.value.hint : ""' persistent-hint ) + v-textarea( + v-else-if='cfg.value.type === "string" && cfg.value.multiline' + outline + background-color='grey lighten-2' + :key='cfg.key' + :label='cfg.value.title' + v-model='cfg.value.value' + prepend-icon='settings_applications' + :hint='cfg.value.hint ? cfg.value.hint : ""' + persistent-hint + :class='cfg.value.hint ? "mb-2" : ""' + ) v-text-field( v-else outline diff --git a/client/components/admin/admin-storage.vue b/client/components/admin/admin-storage.vue index 43ca67e2..7709bbfc 100644 --- a/client/components/admin/admin-storage.vue +++ b/client/components/admin/admin-storage.vue @@ -114,6 +114,18 @@ :hint='cfg.value.hint ? cfg.value.hint : ""' persistent-hint ) + v-textarea( + v-else-if='cfg.value.type === "string" && cfg.value.multiline' + outline + background-color='grey lighten-2' + :key='cfg.key' + :label='cfg.value.title' + v-model='cfg.value.value' + prepend-icon='settings_applications' + :hint='cfg.value.hint ? cfg.value.hint : ""' + persistent-hint + :class='cfg.value.hint ? "mb-2" : ""' + ) v-text-field( v-else outline diff --git a/server/helpers/common.js b/server/helpers/common.js index c4319bd8..febed7d6 100644 --- a/server/helpers/common.js +++ b/server/helpers/common.js @@ -31,6 +31,7 @@ module.exports = { title: value.title || _.startCase(key), hint: value.hint || false, enum: value.enum || false, + multiline: value.multiline || false, order: value.order || 100 }) return result diff --git a/server/modules/authentication/saml/definition.yml b/server/modules/authentication/saml/definition.yml index c0ef9054..ea0e8a14 100644 --- a/server/modules/authentication/saml/definition.yml +++ b/server/modules/authentication/saml/definition.yml @@ -27,16 +27,19 @@ props: type: String title: Certificate hint: (Optional) - Public PEM-encoded X.509 signing certificate. If the provider has multiple certificates that are valid, join them together using the | pipe symbol. + multiline: true order: 4 privateCert: type: String title: Private Certificate hint: (Optional) - PEM formatted key used to sign the certificate. + multiline: true order: 5 decryptionPvk: type: String title: Decryption Private Key hint: (Optional) - Private key that will be used to attempt to decrypt any encrypted assertions that are received. + multiline: true order: 6 signatureAlgorithm: type: String diff --git a/server/modules/storage/git/definition.yml b/server/modules/storage/git/definition.yml index 35ccf754..501e28d9 100644 --- a/server/modules/storage/git/definition.yml +++ b/server/modules/storage/git/definition.yml @@ -29,51 +29,68 @@ props: branch: type: String default: 'master' + hint: The branch to use during pull / push order: 3 + sshPrivateKeyMode: + type: String + title: SSH Private Key Mode + hint: SSH Authentication Only - The mode to use to load the private key. Fill in the corresponding field below. + order: 11 + default: 'path' + enum: + - 'path' + - 'contents' + sshPrivateKeyPath: + type: String + title: A - SSH Private Key Path + hint: SSH Authentication Only - Absolute path to the key. The key must NOT be passphrase-protected. Mode must be set to path to use this option. + order: 12 + sshPrivateKeyContent: + type: String + title: B - SSH Private Key Contents + hint: SSH Authentication Only - Paste the contents of the private key. The key must NOT be passphrase-protected. Mode must be set to contents to use this option. + multiline: true + order: 13 verifySSL: type: Boolean default: true title: Verify SSL Certificate hint: Some hosts requires SSL certificate checking to be disabled. Leave enabled for proper security. - order: 31 - sshPrivateKeyPath: - type: String - title: SSH Private Key Path - hint: SSH Authentication Only - Absolute path to the key. The key must NOT be passphrase-protected. - order: 10 + order: 14 basicUsername: type: String title: Username hint: Basic Authentication Only - order: 11 + order: 20 basicPassword: type: String title: Password / PAT hint: Basic Authentication Only - order: 12 + order: 21 + defaultEmail: + type: String + title: Default Author Email + default: 'name@company.com' + hint: 'Used as fallback in case the author of the change is not present.' + order: 22 + defaultName: + type: String + title: Default Author Name + default: 'John Smith' + hint: 'Used as fallback in case the author of the change is not present.' + order: 23 localRepoPath: type: String title: Local Repository Path default: './data/repo' hint: 'Path where the local git repository will be created.' order: 30 - defaultEmail: - type: String - title: Default Author Email - default: 'name@company.com' - hint: 'Used as fallback in case the author of the change is not present.' - order: 20 - defaultName: - type: String - title: Default Author Name - default: 'John Smith' - hint: 'Used as fallback in case the author of the change is not present.' - order: 21 gitBinaryPath: type: String title: Git Binary Path default: '' hint: Optional - Absolute path to the Git binary, when not available in PATH. Leave empty to use the default PATH location (recommended). + order: 50 actions: - handler: syncUntracked label: Add Untracked Changes diff --git a/server/modules/storage/git/storage.js b/server/modules/storage/git/storage.js index fc2621f9..d00f44b9 100644 --- a/server/modules/storage/git/storage.js +++ b/server/modules/storage/git/storage.js @@ -104,6 +104,18 @@ module.exports = { switch (this.config.authType) { case 'ssh': WIKI.logger.info('(STORAGE/GIT) Setting SSH Command config...') + if (this.config.sshPrivateKeyMode === 'contents') { + try { + this.config.sshPrivateKeyPath = path.join(WIKI.ROOTPATH, 'data/secure/git-ssh.pem') + await fs.outputFile(this.config.sshPrivateKeyPath, this.config.sshPrivateKeyContent, { + encoding: 'utf8', + mode: 0o600 + }) + } catch (err) { + console.error(err) + throw err + } + } await this.git.addConfig('core.sshCommand', `ssh -i "${this.config.sshPrivateKeyPath}" -o StrictHostKeyChecking=no`) WIKI.logger.info('(STORAGE/GIT) Adding origin remote via SSH...') await this.git.addRemote('origin', this.config.repoUrl)