summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-08-23 13:31:02 -0700
committerStan Hu <stanhu@gmail.com>2015-08-23 13:31:02 -0700
commit4016a4577c6f41354e9261e08fe94d917bc9edc2 (patch)
treebb6db4075d062003064291a24022a47d3dc020ab /config
parent97cc91d21d28a6482dc6ab040db31598a786f56c (diff)
downloadgitlab-ce-4016a4577c6f41354e9261e08fe94d917bc9edc2.tar.gz
Only include base URL in OmniAuth full_host parameter
Closes #2335
Diffstat (limited to 'config')
-rw-r--r--config/initializers/1_settings.rb26
-rw-r--r--config/initializers/7_omniauth.rb2
2 files changed, 19 insertions, 9 deletions
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index bd26ac1da20..c47e5dab27c 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -8,7 +8,7 @@ class Settings < Settingslogic
def gitlab_on_standard_port?
gitlab.port.to_i == (gitlab.https ? 443 : 80)
end
-
+
# get host without www, thanks to http://stackoverflow.com/a/6674363/1233435
def get_host_without_www(url)
url = URI.encode(url)
@@ -32,14 +32,12 @@ class Settings < Settingslogic
end
end
+ def build_base_gitlab_url
+ base_gitlab_url.join('')
+ end
+
def build_gitlab_url
- custom_port = gitlab_on_standard_port? ? nil : ":#{gitlab.port}"
- [ gitlab.protocol,
- "://",
- gitlab.host,
- custom_port,
- gitlab.relative_url_root
- ].join('')
+ (base_gitlab_url + [gitlab.relative_url_root]).join('')
end
# check that values in `current` (string or integer) is a contant in `modul`.
@@ -64,6 +62,17 @@ class Settings < Settingslogic
end
value
end
+
+ private
+
+ def base_gitlab_url
+ custom_port = gitlab_on_standard_port? ? nil : ":#{gitlab.port}"
+ [ gitlab.protocol,
+ "://",
+ gitlab.host,
+ custom_port
+ ]
+ end
end
end
@@ -123,6 +132,7 @@ Settings.gitlab['email_enabled'] ||= true if Settings.gitlab['email_enabled'].ni
Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}"
Settings.gitlab['email_display_name'] ||= "GitLab"
Settings.gitlab['email_reply_to'] ||= "noreply@#{Settings.gitlab.host}"
+Settings.gitlab['base_url'] ||= Settings.send(:build_base_gitlab_url)
Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url)
Settings.gitlab['user'] ||= 'git'
Settings.gitlab['user_home'] ||= begin
diff --git a/config/initializers/7_omniauth.rb b/config/initializers/7_omniauth.rb
index 7f73546ac89..70ed10e8275 100644
--- a/config/initializers/7_omniauth.rb
+++ b/config/initializers/7_omniauth.rb
@@ -11,7 +11,7 @@ if Gitlab::LDAP::Config.enabled?
end
end
-OmniAuth.config.full_host = Settings.gitlab['url']
+OmniAuth.config.full_host = Settings.gitlab['base_url']
OmniAuth.config.allowed_request_methods = [:post]
#In case of auto sign-in, the GET method is used (users don't get to click on a button)
OmniAuth.config.allowed_request_methods << :get if Gitlab.config.omniauth.auto_sign_in_with_provider.present?