Allow GitHub imports via token even if OAuth2 provider not configured

Previously, the GitHub importer would only work if the site configured
an OAuth2 provider were configured. Users attempting to import via a
GitHub personal access token would see an Error 500 due to a failed
redirection. We fix this by only doing the redirection if the provider
has been configured and allowing users to see the new import page.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/38524
This commit is contained in:
Stan Hu 2018-12-10 11:52:04 -08:00
parent eadd53b969
commit b4e2679437
3 changed files with 15 additions and 1 deletions

View File

@ -7,7 +7,7 @@ class Import::GithubController < Import::BaseController
rescue_from Octokit::Unauthorized, with: :provider_unauthorized
def new
if logged_in_with_provider?
if github_import_configured? && logged_in_with_provider?
go_to_provider_for_permissions
elsif session[access_token_key]
redirect_to status_import_url

View File

@ -0,0 +1,5 @@
---
title: Allow GitHub imports via token even if OAuth2 provider not configured
merge_request: 23703
author:
type: fixed

View File

@ -16,6 +16,15 @@ describe Import::GithubController do
get :new
end
it "prompts for an access token if GitHub not configured" do
allow(controller).to receive(:github_import_configured?).and_return(false)
expect(controller).not_to receive(:go_to_provider_for_permissions)
get :new
expect(response).to have_http_status(200)
end
end
describe "GET callback" do