From 816a6c01749185d655285b5c518c0c6eecd72f9c Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 16 Feb 2021 08:56:01 +0200 Subject: [PATCH 1/3] Print HTPasswd user credentials Signed-off-by: Anatolii Bazko --- src/tasks/che.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tasks/che.ts b/src/tasks/che.ts index 99d9132e3..3dd5a19cc 100644 --- a/src/tasks/che.ts +++ b/src/tasks/che.ts @@ -675,7 +675,20 @@ export class CheTasks { const cheUrl = await this.che.cheURL(flags.chenamespace) messages.push(`Users Dashboard : ${cheUrl}`) - messages.push('Admin user login : "admin:admin". NOTE: must change after first login.') + + const cr = await this.kube.getCheCluster(flags.chenamespace) + if (ctx.isOpenShift && cr && cr.spec && cr.spec.auth && cr.spec.auth.openShiftoAuth) { + if (cr.status && cr.status.openShiftOAuthUserCredentialsSecret) { + const credentialsSecret = await this.kube.getSecret(cr.status.openShiftOAuthUserCredentialsSecret, flags.chenamespace) + if (credentialsSecret) { + const user = credentialsSecret.data!['user'] + const password = credentialsSecret.data!['password'] + messages.push(`HTPasswd user credentials : "${user}:${password}".`) + } + } + } else { + messages.push('Admin user login : "admin:admin". NOTE: must change after first login.') + } messages.push(OUTPUT_SEPARATOR) const cheConfigMap = await this.kube.getConfigMap('che', flags.chenamespace) From 53990e3ecec3ab29405132227b7ec96f28daac96 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 16 Feb 2021 09:19:10 +0200 Subject: [PATCH 2/3] Decode credentials Signed-off-by: Anatolii Bazko --- src/tasks/che.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tasks/che.ts b/src/tasks/che.ts index 3dd5a19cc..dbe45d41f 100644 --- a/src/tasks/che.ts +++ b/src/tasks/che.ts @@ -9,6 +9,7 @@ **********************************************************************/ import { Command } from '@oclif/command' import * as Listr from 'listr' +import { base64Decode } from '../util' import { CheHelper } from '../api/che' import { CheApiClient } from '../api/che-api-client' @@ -681,8 +682,8 @@ export class CheTasks { if (cr.status && cr.status.openShiftOAuthUserCredentialsSecret) { const credentialsSecret = await this.kube.getSecret(cr.status.openShiftOAuthUserCredentialsSecret, flags.chenamespace) if (credentialsSecret) { - const user = credentialsSecret.data!['user'] - const password = credentialsSecret.data!['password'] + const user = base64Decode(credentialsSecret.data!['user']) + const password = base64Decode(credentialsSecret.data!['password']) messages.push(`HTPasswd user credentials : "${user}:${password}".`) } } From 6a246e5903f2f9171d05dddb614f28016ab75c13 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Tue, 16 Feb 2021 09:35:59 +0200 Subject: [PATCH 3/3] Fix errors Signed-off-by: Anatolii Bazko --- src/tasks/che.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tasks/che.ts b/src/tasks/che.ts index dbe45d41f..5cfe40919 100644 --- a/src/tasks/che.ts +++ b/src/tasks/che.ts @@ -9,7 +9,6 @@ **********************************************************************/ import { Command } from '@oclif/command' import * as Listr from 'listr' -import { base64Decode } from '../util' import { CheHelper } from '../api/che' import { CheApiClient } from '../api/che-api-client' @@ -18,6 +17,7 @@ import { KubeHelper } from '../api/kube' import { OpenShiftHelper } from '../api/openshift' import { VersionHelper } from '../api/version' import { CHE_OPERATOR_SELECTOR, DOC_LINK, DOC_LINK_RELEASE_NOTES, OUTPUT_SEPARATOR } from '../constants' +import { base64Decode } from '../util' import { KubeTasks } from './kube' @@ -682,8 +682,8 @@ export class CheTasks { if (cr.status && cr.status.openShiftOAuthUserCredentialsSecret) { const credentialsSecret = await this.kube.getSecret(cr.status.openShiftOAuthUserCredentialsSecret, flags.chenamespace) if (credentialsSecret) { - const user = base64Decode(credentialsSecret.data!['user']) - const password = base64Decode(credentialsSecret.data!['password']) + const user = base64Decode(credentialsSecret.data!.user) + const password = base64Decode(credentialsSecret.data!.password) messages.push(`HTPasswd user credentials : "${user}:${password}".`) } }