summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-04-28 09:37:13 +0000
committerRémy Coutable <remy@rymai.me>2016-04-28 09:37:13 +0000
commit7aff855bc7f0ac5a688df7dcafffbdc617882fc1 (patch)
tree362322c4267fee937522c5e3d5b427ff859730d0 /config
parenta792427eed95570da22844a06a09227730443189 (diff)
parentc47183d78723a30733dc465f72e37299d8628363 (diff)
downloadgitlab-ce-7aff855bc7f0ac5a688df7dcafffbdc617882fc1.tar.gz
Merge branch 'fix-github-enterprise-imports' into 'master'
Backport GitHub Enterprise import support from EE These changes were pulled from GitLab EE to support configuring an alternative API URL than the default https://api.github.com. In addition, the `verify_ssl` flag allows users to disable SSL cert checking. One modification: add a default `args` option if it does not exist to avoid breaking existing configurations. See merge request !3892
Diffstat (limited to 'config')
-rw-r--r--config/gitlab.yml.example2
-rw-r--r--config/initializers/1_settings.rb24
2 files changed, 26 insertions, 0 deletions
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index d9c15f81404..2790f1c8a29 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -350,6 +350,8 @@ production: &base
# - { name: 'github',
# app_id: 'YOUR_APP_ID',
# app_secret: 'YOUR_APP_SECRET',
+ # url: "https://github.com/",
+ # verify_ssl: true,
# args: { scope: 'user:email' } }
# - { name: 'bitbucket',
# app_id: 'YOUR_APP_ID',
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 10c25044b75..6eb144d043b 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -140,6 +140,30 @@ Settings.omniauth.cas3['session_duration'] ||= 8.hours
Settings.omniauth['session_tickets'] ||= Settingslogic.new({})
Settings.omniauth.session_tickets['cas3'] = 'ticket'
+# Fill out omniauth-gitlab settings. It is needed for easy set up GHE or GH by just specifying url.
+
+github_default_url = "https://github.com"
+github_settings = Settings.omniauth['providers'].find { |provider| provider["name"] == "github" }
+
+if github_settings
+ # For compatibility with old config files (before 7.8)
+ # where people dont have url in github settings
+ if github_settings['url'].blank?
+ github_settings['url'] = github_default_url
+ end
+
+ github_settings["args"] ||= Settingslogic.new({})
+
+ if github_settings["url"].include?(github_default_url)
+ github_settings["args"]["client_options"] = OmniAuth::Strategies::GitHub.default_options[:client_options]
+ else
+ github_settings["args"]["client_options"] = {
+ "site" => File.join(github_settings["url"], "api/v3"),
+ "authorize_url" => File.join(github_settings["url"], "login/oauth/authorize"),
+ "token_url" => File.join(github_settings["url"], "login/oauth/access_token")
+ }
+ end
+end
Settings['shared'] ||= Settingslogic.new({})
Settings.shared['path'] = File.expand_path(Settings.shared['path'] || "shared", Rails.root)