Commit 9de15c1e authored by Valery Sizov's avatar Valery Sizov

GHE importer: single configuration for auth and importer

parent fb638cc8
......@@ -258,14 +258,20 @@ production: &base
# args: { access_type: 'offline', approval_prompt: '' } }
# - { name: 'twitter', app_id: 'YOUR APP ID',
# app_secret: 'YOUR APP SECRET'}
# - { name: 'github', app_id: 'YOUR APP ID',
# - { name: 'gitlab', app_id: 'YOUR APP ID',
# app_secret: 'YOUR APP SECRET',
# args: { scope: 'user:email' } }
# Github Enterprise
#- { name: 'github', app_id: 'YOUR APP ID',
# app_secret: 'YOUR APP SECRET',
# url: "https://github.example.com/", args: { scope: 'user:email' } }
# args: { scope: 'api' } }
# - { name: 'github', app_id: '01723ee0027dd2b496d9',
# app_secret: '7f4b9298d181375e51cd60e25e9f26603a4dd3cc',
# args: {
# scope: 'user:email',
# client_options: {
# site: 'https://api.github.com/',
# authorize_url: 'https://github.com/login/oauth/authorize',
# token_url: 'https://github.com/login/oauth/access_token'
# }
# }
# }
......
......@@ -32,11 +32,38 @@ To enable the GitHub OmniAuth provider you must register your application with G
1. Under `providers:` uncomment (or add) lines that look like the following:
```
- { name: 'github', app_id: 'YOUR APP ID',
app_secret: 'YOUR APP SECRET',
args: { scope: 'user:email' } }
- { name: 'github', app_id: '01723ee0027dd2b496d9',
app_secret: '7f4b9298d181375e51cd60e25e9f26603a4dd3cc',
args: {
scope: 'user:email',
client_options: {
site: 'https://api.github.com/',
authorize_url: 'https://github.com/login/oauth/authorize',
token_url: 'https://github.com/login/oauth/access_token'
}
}
}
```
1. If you want to use GitHub Enterprise then your configuration should look like the following:
```
- { name: 'github', app_id: 'a4eaa26df2ff35879923',
app_secret: '2f9236c341cf8b3dc86a93652554fccd4ef84c55',
args: {
scope: 'user:email',
client_options: {
site: 'https://github.example.com/api/v3',
authorize_url: 'https://github.example.com/login/oauth/authorize',
token_url: 'https://github.example.com/login/oauth/access_token'
}
}
}
```
1. Change 'YOUR APP ID' to the client ID from the GitHub application page from step 7.
1. Change 'YOUR APP SECRET' to the client secret from the GitHub application page from step 7.
......
......@@ -12,7 +12,7 @@ module Gitlab
if access_token
::Octokit.auto_paginate = true
@api = ::Octokit::Client.new(access_token: access_token, api_endpoint: api_endpoint)
@api = ::Octokit::Client.new(access_token: access_token, api_endpoint: github_options[:site])
end
end
......@@ -45,16 +45,8 @@ module Gitlab
Gitlab.config.omniauth.providers.find{|provider| provider.name == "github"}
end
def api_endpoint
File.join(config["url"], "/api/v3/") if config["url"]
end
def github_options
{
site: config["url"] || 'https://api.github.com',
authorize_url: '/login/oauth/authorize',
token_url: '/login/oauth/access_token'
}
config["args"]["client_options"].deep_symbolize_keys
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment