Skip to content

Commit

Permalink
WIP: minor fixes, force host if https enabled in UI
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
  • Loading branch information
andrey18106 committed Jan 24, 2024
1 parent cd703df commit 6544271
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/DeployActions/DockerActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,22 +514,22 @@ public function initGuzzleClient(DaemonConfig $daemonConfig): void {
],
];
} elseif ($daemonConfig->getProtocol() === 'https') {
$guzzleParams = $this->setupCerts($guzzleParams, $daemonConfig->getDeployConfig());
$guzzleParams = $this->setupCerts($guzzleParams);
}
if (!empty($daemonConfig->getDeployConfig()['haproxy_password'])) {
$guzzleParams['auth'] = [self::APP_API_HAPROXY_USER, $daemonConfig->getDeployConfig()['haproxy_password']];
}
$this->guzzleClient = new Client($guzzleParams);
}

private function setupCerts(array $guzzleParams, array $deployConfig): array {
private function setupCerts(array $guzzleParams): array {
if (!$this->config->getSystemValueBool('installed', false)) {
$certs = \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
} else {
$certs = $this->certificateManager->getAbsoluteBundlePath();
}

$guzzleParams['verify'] = $certs;
if (!empty($deployConfig['haproxy_password'])) {
$guzzleParams['auth'] = [self::APP_API_HAPROXY_USER, $deployConfig['haproxy_password']];
}
return $guzzleParams;
}

Expand Down
32 changes: 27 additions & 5 deletions src/components/DaemonConfig/RegisterDaemonConfigModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,20 @@
</template>
</NcButton>
<div v-show="deployConfigSettingsOpened" class="deploy-config" :aria-label="t('app_api', 'Deploy config')">
<div class="external-label" :aria-label="t('app_api', 'Network')">
<div class="external-label"
:aria-label="t('app_api', 'Network')">
<label for="deploy-config-net">{{ t('app_api', 'Network') }}</label>
<NcInputField
id="deploy-config-net"
:value.sync="deployConfig.net"
:disabled="daemonProtocol === 'https'"
:placeholder="t('app_api', 'Docker network name')"
:aria-label="t('app_api', 'Docker network name')"
:helper-text="t('app_api', 'Docker network name')" />
:helper-text="networkHelperText" />
</div>
<div v-if="['http', 'https'].includes(daemonProtocol)" class="external-label" :aria-label="t('app_api', 'HaProxy password')">
<div v-if="['http', 'https'].includes(daemonProtocol)"
class="external-label"
:aria-label="t('app_api', 'HaProxy password')">
<label for="deploy-config-haproxy-password">{{ t('app_api', 'HaProxy password') }}</label>
<NcInputField
id="deploy-config-haproxy-password"
Expand Down Expand Up @@ -124,7 +128,7 @@
<div class="row">
<NcButton
type="primary"
:disabled="isDaemonNameValid === true && isHaProxyPasswordValid === true"
:disabled="canRegister"
@click="registerDaemon">
{{ t('app_api', 'Register') }}
<template #icon>
Expand Down Expand Up @@ -248,11 +252,21 @@ export default {
if (this.daemonProtocol === 'https') {
return this.deployConfig.haproxy_password !== null && this.deployConfig.haproxy_password.length >= 12
}
// HaProxy password required only for https
return true
},
haProxyPasswordHelperText() {
return this.isHaProxyPasswordValid ? t('app_api', 'AppAPI Docker Socket Proxy authentication password') : t('app_api', 'Password must be at least 12 characters long')
},
networkHelperText() {
if (this.httpsEnabled) {
return t('app_api', 'With https enabled network is set to host')
}
return t('app_api', 'Docker network name')
},
canRegister() {
return this.isDaemonNameValid === true || this.isHaProxyPasswordValid === false
},
},
watch: {
configurationTab(newConfigurationTab) {
Expand All @@ -268,6 +282,14 @@ export default {
this.configurationTab = { id: this.configurationTab.id, label: this.configurationTab.label }
}
},
httpsEnabled(newHttpsEnabled) {
if (newHttpsEnabled) {
this.prevNet = this.deployConfig.net
this.deployConfig.net = 'host'
} else {
this.deployConfig.net = this.prevNet
}
},
},
methods: {
registerDaemon() {
Expand Down Expand Up @@ -352,7 +374,7 @@ export default {
}
},
closeModal() {
const customTemplate = DAEMON_TEMPLATES.find(template => template.name === this.configurationTab.id)
const customTemplate = DAEMON_TEMPLATES.find(template => template.id === 'custom')
this.configurationTab = { id: customTemplate.id, label: customTemplate.displayName }
this.$emit('update:show', false)
},
Expand Down

0 comments on commit 6544271

Please sign in to comment.