Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Add option to have the default application URL use https - updated
Browse files Browse the repository at this point in the history
  • Loading branch information
oybed committed Mar 17, 2015
1 parent ead85cc commit 3a0e7d2
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions broker/conf/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ CART_DOWNLOAD_CONN_TIMEOUT="2"
#
# HTTP_PROXY="proxy.server.com:3128"

# Set to "true" to make application default to use https in advertised URL
APP_ADVERTISE_HTTPS="false"

# Team collaboration settings
MAX_MEMBERS_PER_RESOURCE="100"
MAX_TEAMS_PER_RESOURCE="5"
Expand Down
1 change: 1 addition & 0 deletions broker/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
:normalize_username_method => conf.get("NORMALIZE_USERNAME_METHOD", "noop"),
:use_predictable_gear_uuids => conf.get_bool("USE_PREDICTABLE_GEAR_UUIDS", false),
:limit_app_name_chars => conf.get("LIMIT_APP_NAME_CHARS", -1).to_i,
:app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false),
}

config.auth = {
Expand Down
1 change: 1 addition & 0 deletions broker/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
:normalize_username_method => conf.get("NORMALIZE_USERNAME_METHOD", "noop"),
:use_predictable_gear_uuids => conf.get_bool("USE_PREDICTABLE_GEAR_UUIDS", false),
:limit_app_name_chars => conf.get("LIMIT_APP_NAME_CHARS", -1).to_i,
:app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false),
}

config.auth = {
Expand Down
1 change: 1 addition & 0 deletions broker/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
:normalize_username_method => conf.get("NORMALIZE_USERNAME_METHOD", "noop"),
:use_predictable_gear_uuids => conf.get_bool("USE_PREDICTABLE_GEAR_UUIDS", false),
:limit_app_name_chars => conf.get("LIMIT_APP_NAME_CHARS", -1).to_i,
:app_advertise_https => conf.get_bool("APP_ADVERTISE_HTTPS", false),
}

config.auth = {
Expand Down
8 changes: 8 additions & 0 deletions controller/app/models/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,14 @@ def fqdn(gear_name = nil)
"#{gear_name || canonical_name}-#{domain_namespace}.#{Rails.configuration.openshift[:domain_suffix]}"
end

##
# Returns the application URL with the proper protocol (http vs https) based on configuration
# @return [String]
def app_url
proto = Rails.application.config.openshift[:app_advertise_https] ? "https" : "http"
"#{proto}://#{fqdn()}/"
end

##
# Returns the SSH URI for an application gear (unless specified, the primary)
# @return [String]
Expand Down
2 changes: 1 addition & 1 deletion controller/app/rest_models/rest_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def initialize(app, url, nolinks=false, applications=nil)
self.git_url = "ssh://#{ssh_uri}/~/git/#{@name}.git/"
self.ssh_url = "ssh://#{ssh_uri}"
end
self.app_url = "http://#{app.fqdn}/"
self.app_url = app.app_url
self.health_check_path = app.health_check_path

self.building_with = nil
Expand Down
2 changes: 1 addition & 1 deletion controller/app/rest_models/rest_application10.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def initialize(app, url, nolinks=false, applications=nil)
self.git_url = "ssh://#{ssh_uri}/~/git/#{@name}.git/"
self.ssh_url = "ssh://#{ssh_uri}"
end
self.app_url = "http://#{app.fqdn}/"
self.app_url = app.app_url
self.health_check_path = app.health_check_path

self.building_with = nil
Expand Down
2 changes: 1 addition & 1 deletion controller/app/rest_models/rest_application13.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(app, url, nolinks=false, applications=nil)
self.git_url = "ssh://#{ssh_uri}/~/git/#{@name}.git/"
self.ssh_url = "ssh://#{ssh_uri}"
end
self.app_url = "http://#{app.fqdn}/"
self.app_url = app.app_url
self.health_check_path = app.health_check_path

self.building_with = nil
Expand Down
2 changes: 1 addition & 1 deletion controller/app/rest_models/rest_application15.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def initialize(app, url, nolinks=false, applications=nil)
self.git_url = "ssh://#{ssh_uri}/~/git/#{@name}.git/"
self.ssh_url = "ssh://#{ssh_uri}"
end
self.app_url = "http://#{app.fqdn}/"
self.app_url = app.app_url
self.health_check_path = app.health_check_path

self.building_with = nil
Expand Down

0 comments on commit 3a0e7d2

Please sign in to comment.