Skip to content

Commit

Permalink
Fix Codenvy issue 1708
Browse files Browse the repository at this point in the history
Handle host protocol property (and use ssl if defined)

Change-Id: If8a470d7c531087a93ec7d29331a6444d885b88b
Signed-off-by: Florent BENOIT <fbenoit@codenvy.com>
  • Loading branch information
benoitf committed Mar 27, 2017
1 parent 6f96117 commit f2363ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
8 changes: 7 additions & 1 deletion dockerfiles/base/scripts/base/startup_04_pre_cli_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ cli_init() {
CLI_ENV=${CLI_ENV%*]}
IFS=' ' read -r -a CLI_ENV_ARRAY <<< "$CLI_ENV"

if is_initialized; then
CHE_HOST_PROTOCOL="http"
if is_initialized; then
CHE_HOST_LOCAL=$(get_value_of_var_from_env_file ${CHE_PRODUCT_NAME}_HOST)
CHE_HOST_ENV=$(get_value_of_var_from_env ${CHE_PRODUCT_NAME}_HOST)
if [[ "${CHE_HOST_ENV}" != "" ]] &&
Expand All @@ -45,6 +46,11 @@ cli_init() {
CHE_HOST=$CHE_HOST_ENV
fi

CHE_HOST_PROTOCOL_ENV=$(get_value_of_var_from_env_file ${CHE_PRODUCT_NAME}_HOST_PROTOCOL)
if [[ "${CHE_HOST_PROTOCOL_ENV}" != "" ]]; then
CHE_HOST_PROTOCOL=${CHE_HOST_PROTOCOL_ENV}
fi

if [[ "${CHE_HOST_ENV}" = "" ]] &&
[[ "${CHE_HOST_LOCAL}" != "" ]]; then
CHE_HOST=${CHE_HOST_LOCAL}
Expand Down
18 changes: 14 additions & 4 deletions dockerfiles/lib/src/api/wsmaster/auth/auth-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export class AuthData {
if (hostname) {
this.hostname = hostname;
} else {
this.hostname = this.DEFAULT_HOSTNAME;
// handle CHE_HOST if any
if (process.env.CHE_HOST) {
this.hostname = process.env.CHE_HOST;
} else {
this.hostname = this.DEFAULT_HOSTNAME;
}
}

if (port) {
Expand All @@ -51,6 +56,13 @@ export class AuthData {
}
}

let hostProtocol :string = process.env.CHE_HOST_PROTOCOL;
if (hostProtocol && hostProtocol === "https") {
this.secured = true;
if (this.port == 80) {
this.port = 443;
}
}

if (token) {
this.token = token;
Expand Down Expand Up @@ -178,9 +190,7 @@ export class AuthData {
}

let authData: AuthData = new AuthData(urlObject.hostname, port);
if (isSecured) {
authData.secured = true;
}
authData.secured = isSecured;

authData.username = username;
authData.password = password;
Expand Down

0 comments on commit f2363ae

Please sign in to comment.