Skip to content

Commit bb044c4

Browse files
committed
Reapply "feat(welcome): add GenerateRegistrationToken on FirstHost slideout"
This reverts commit f8e5f0f. Change-Id: Ic2a9660c6c9bde0e7bbb730e965ab72a1fc95f9e
1 parent c0f9902 commit bb044c4

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

packages/cmk-frontend-vue/src/welcome/components/first-host/FirstHostSlideout.vue

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ conditions defined in the file COPYING, which is part of this source code packag
55
-->
66

77
<script setup lang="ts">
8-
import { onMounted, ref } from 'vue'
8+
import { ref } from 'vue'
99
1010
import usei18n from '@/lib/i18n'
1111
import usePersistentRef from '@/lib/usePersistentRef'
@@ -23,8 +23,9 @@ import CmkWizardStep from '@/components/CmkWizard/CmkWizardStep.vue'
2323
import CmkHeading from '@/components/typography/CmkHeading.vue'
2424
import CmkParagraph from '@/components/typography/CmkParagraph.vue'
2525
26+
import GenerateToken from '@/mode-host/agent-connection-test/components/GenerateToken.vue'
27+
2628
import { finalStepText, tabs } from './FirstHostSlideoutContent'
27-
import { CseOnboardingApiClient } from './onboarding-api-client'
2829
2930
const { _t } = usei18n()
3031
@@ -35,8 +36,7 @@ const openedTab = usePersistentRef<string | number>(
3536
(v) => v as string | number
3637
)
3738
const currentStep = ref<number>(1)
38-
const onboardingApiClient = new CseOnboardingApiClient('api/v1/')
39-
const agentSecret = ref<string | null>(null)
39+
const ott = ref<string | null | Error>(null)
4040
4141
function onClose() {
4242
slideInOpen.value = false
@@ -46,16 +46,6 @@ function onClose() {
4646
function goToHostOverview() {
4747
window.location.href = 'wato.py?mode=folder'
4848
}
49-
50-
onMounted(async () => {
51-
try {
52-
if (!agentSecret.value) {
53-
agentSecret.value = (await onboardingApiClient.getAgentSecret()).secret
54-
}
55-
} catch (e) {
56-
console.error('Failed to fetch agent download information', e)
57-
}
58-
})
5949
</script>
6050

6151
<template>
@@ -98,23 +88,26 @@ onMounted(async () => {
9888
<CmkParagraph>
9989
{{ step.description_top }}
10090
</CmkParagraph>
101-
<CmkCode
102-
:code_txt="
103-
step.code.replace(
104-
'[AGENT_DOWNLOAD_SECRET]',
105-
agentSecret || '<agent-download-secret>'
106-
)
107-
"
108-
class="welcome-first-host-slideout__code"
91+
<GenerateToken
92+
v-if="currentStep === 1"
93+
v-model="ott"
94+
token-generation-endpoint-uri="domain-types/agent_download_token/collections/all"
95+
:description="_t('This requires the generation of a download token.')"
96+
:token-generation-body="{
97+
expires_at: null
98+
}"
10999
/>
110-
<CmkParagraph v-if="step.description_bottom">
111-
{{ step.description_bottom }}
112-
</CmkParagraph>
113-
<CmkSpace></CmkSpace>
100+
<template v-if="typeof ott === 'string'">
101+
<CmkCode
102+
:code_txt="step.code.replace('[AGENT_DOWNLOAD_OTT]', ott)"
103+
class="welcome-first-host-slideout__code"
104+
/>
105+
<CmkSpace></CmkSpace>
106+
</template>
114107
</template>
115108

116109
<template #actions>
117-
<CmkWizardButton type="next" />
110+
<CmkWizardButton type="next" :disabled="ott === null" />
118111
<CmkWizardButton v-if="step.stepNumber > 1" type="previous" />
119112
</template>
120113
</CmkWizardStep>

packages/cmk-frontend-vue/src/welcome/components/first-host/FirstHostSlideoutContent.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const step1Note = _t(
3333
)
3434
const downloadUrl =
3535
`${window.location.href.substring(0, window.location.href.indexOf('/check_mk/') + 9)}` +
36-
'/api/1.0/domain-types/agent/actions/download_by_host/' +
37-
'invoke?folder_name=%2Fpreconfigured_agent%2F&os_type=[OS_TYPE]&agent_type=generic'
36+
'/api/internal/domain-types/agent/actions/download_by_host_via_token/' +
37+
'invoke?folder=%2Fpreconfigured_agent%2F&os_type=[OS_TYPE]&agent_type=generic'
3838

3939
export const tabs: FirstHostTabs[] = [
4040
{
@@ -51,7 +51,7 @@ export const tabs: FirstHostTabs[] = [
5151
'(\n' +
5252
'curl -o check-mk-agent.deb \\\n' +
5353
'--header "Accept: application/octet-stream" \\\n' +
54-
'--header "Authorization: Bearer agent_download [AGENT_DOWNLOAD_SECRET]" \\\n' +
54+
'--header "Authorization: CMK-TOKEN 0:[AGENT_DOWNLOAD_OTT]" \\\n' +
5555
`"${downloadUrl.replace('[OS_TYPE]', 'linux_deb')}"\n` +
5656
');'
5757
},
@@ -80,7 +80,7 @@ export const tabs: FirstHostTabs[] = [
8080
'(\n' +
8181
'curl -o check-mk-agent.rpm \\\n' +
8282
'--header "Accept: application/octet-stream" \\\n' +
83-
'--header "Authorization: Bearer agent_download [AGENT_DOWNLOAD_SECRET]" \\\n' +
83+
'--header "Authorization: CMK-TOKEN 0:[AGENT_DOWNLOAD_OTT]" \\\n' +
8484
`"${downloadUrl.replace('[OS_TYPE]', 'linux_rpm')}"\n` +
8585
');'
8686
},
@@ -109,7 +109,7 @@ export const tabs: FirstHostTabs[] = [
109109
'-Method "GET" `\n' +
110110
'-Headers @{\n' +
111111
' "Accept" = "application/octet-stream";\n' +
112-
' "Authorization" = "Bearer agent_download [AGENT_DOWNLOAD_SECRET]"\n' +
112+
' "Authorization" = "CMK-TOKEN 0:[AGENT_DOWNLOAD_OTT]" \n' +
113113
'}'
114114
},
115115
{

0 commit comments

Comments
 (0)