Commit Graph

51 Commits

Author SHA1 Message Date
GitLab Bot 919e3e3cd8 Add latest changes from gitlab-org/gitlab@master 2023-02-07 21:09:58 +00:00
GitLab Bot 33998a0e76 Add latest changes from gitlab-org/gitlab@master 2023-02-06 18:09:43 +00:00
GitLab Bot 5db6a7a014 Add latest changes from gitlab-org/gitlab@master 2023-01-05 15:08:39 +00:00
GitLab Bot 17c478bc80 Add latest changes from gitlab-org/gitlab@master 2022-12-15 00:08:38 +00:00
GitLab Bot af833d9730 Add latest changes from gitlab-org/gitlab@master 2022-12-02 18:07:23 +00:00
GitLab Bot dcd075c981 Add latest changes from gitlab-org/gitlab@master 2022-10-14 00:10:41 +00:00
GitLab Bot 0cd52ae4af Add latest changes from gitlab-org/gitlab@master 2022-10-13 00:08:53 +00:00
GitLab Bot 146284d119 Add latest changes from gitlab-org/gitlab@master 2022-10-05 12:09:04 +00:00
GitLab Bot 99aa31992d Add latest changes from gitlab-org/gitlab@master 2022-09-15 18:10:36 +00:00
GitLab Bot 57b795ee00 Add latest changes from gitlab-org/gitlab@master 2022-06-22 06:08:52 +00:00
GitLab Bot d2675fa4de Add latest changes from gitlab-org/gitlab@master 2022-06-09 15:09:21 +00:00
GitLab Bot 1843215ebb Add latest changes from gitlab-org/gitlab@master 2022-04-15 09:08:25 +00:00
GitLab Bot e7fb614993 Add latest changes from gitlab-org/gitlab@master 2022-03-31 18:08:39 +00:00
GitLab Bot 82f12c2090 Add latest changes from gitlab-org/gitlab@master 2022-03-23 18:08:47 +00:00
GitLab Bot d237ada361 Add latest changes from gitlab-org/gitlab@master 2022-01-12 00:16:35 +00:00
GitLab Bot 1361891b0a Add latest changes from gitlab-org/gitlab@master 2020-12-09 12:09:42 +00:00
GitLab Bot c19dce027b Add latest changes from gitlab-org/gitlab@master 2020-11-13 21:09:31 +00:00
GitLab Bot bd27a42f54 Add latest changes from gitlab-org/gitlab@master 2020-08-11 12:09:55 +00:00
GitLab Bot 0790cf032c Add latest changes from gitlab-org/gitlab@master 2020-08-06 21:10:15 +00:00
GitLab Bot 58320d8e03 Add latest changes from gitlab-org/gitlab@master 2020-07-29 15:09:39 +00:00
GitLab Bot 640e72ca92 Add latest changes from gitlab-org/gitlab@master 2020-06-04 03:08:05 +00:00
GitLab Bot 0d6fa03312 Add latest changes from gitlab-org/gitlab@master 2020-02-06 18:08:54 +00:00
GitLab Bot 1ce6af4aad Add latest changes from gitlab-org/gitlab@master 2020-01-24 00:08:51 +00:00
Matija Čupić 1f40372029
Do not authorize with OAuth for CICD only projects 2019-07-23 11:48:23 +02:00
gfyoung 93a44e135b Add some frozen string to spec/**/*.rb
Adds frozen string to the following:

* spec/bin/**/*.rb
* spec/config/**/*.rb
* spec/controllers/**/*.rb

xref https://gitlab.com/gitlab-org/gitlab-ce/issues/59758
2019-04-15 10:17:05 +00:00
Luke Bennett 534a61179e
Improve the GitHub and Gitea import feature table interface
These are backend changes.
Use Vue for the import feature UI for "githubish"
providers (GitHub and Gitea).
Add "Go to project" button after a successful import.
Use CI-style status icons and improve spacing of the
table and its component.
Adds ETag polling to the github and gitea import
jobs endpoint.
2019-02-13 00:15:57 +00:00
Stan Hu 88f2e9615c
Alias GitHub and BitBucket OAuth2 callback URLs
To prevent an OAuth2 covert redirect vulnerability, this commit adds and
uses an alias for the GitHub and BitBucket OAuth2 callback URLs to the
following paths:

GitHub: /users/auth/-/import/github
Bitbucket: /users/auth/-/import/bitbucket

This allows admins to put a more restrictive callback URL in the OAuth2
configuration settings. Instead of https://example.com, admins can now use:

https://example.com/users/auth

It's possible but not trivial to change Devise and OmniAuth to use a
different prefix for callback URLs instead of /users/auth. For now,
aliasing the import URLs under the /users/auth namespace should suffice.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56663
2019-01-31 16:52:48 +01:00
Stan Hu b4e2679437 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
2018-12-10 11:56:14 -08:00
Yorick Peterse 4dfe26cd8b
Rewrite the GitHub importer from scratch
Prior to this MR there were two GitHub related importers:

* Github::Import: the main importer used for GitHub projects
* Gitlab::GithubImport: importer that's somewhat confusingly used for
  importing Gitea projects (apparently they have a compatible API)

This MR renames the Gitea importer to Gitlab::LegacyGithubImport and
introduces a new GitHub importer in the Gitlab::GithubImport namespace.
This new GitHub importer uses Sidekiq for importing multiple resources
in parallel, though it also has the ability to import data sequentially
should this be necessary.

The new code is spread across the following directories:

* lib/gitlab/github_import: this directory contains most of the importer
  code such as the classes used for importing resources.
* app/workers/gitlab/github_import: this directory contains the Sidekiq
  workers, most of which simply use the code from the directory above.
* app/workers/concerns/gitlab/github_import: this directory provides a
  few modules that are included in every GitHub importer worker.

== Stages

The import work is divided into separate stages, with each stage
importing a specific set of data. Stages will schedule the work that
needs to be performed, followed by scheduling a job for the
"AdvanceStageWorker" worker. This worker will periodically check if all
work is completed and schedule the next stage if this is the case. If
work is not yet completed this worker will reschedule itself.

Using this approach we don't have to block threads by calling `sleep()`,
as doing so for large projects could block the thread from doing any
work for many hours.

== Retrying Work

Workers will reschedule themselves whenever necessary. For example,
hitting the GitHub API's rate limit will result in jobs rescheduling
themselves. These jobs are not processed until the rate limit has been
reset.

== User Lookups

Part of the importing process involves looking up user details in the
GitHub API so we can map them to GitLab users. The old importer used
an in-memory cache, but this obviously doesn't work when the work is
spread across different threads.

The new importer uses a Redis cache and makes sure we only perform
API/database calls if absolutely necessary.  Frequently used keys are
refreshed, and lookup misses are also cached; removing the need for
performing API/database calls if we know we don't have the data we're
looking for.

== Performance & Models

The new importer in various places uses raw INSERT statements (as
generated by `Gitlab::Database.bulk_insert`) instead of using Rails
models. This allows us to bypass any validations and callbacks,
drastically reducing the number of SQL queries and Gitaly RPC calls
necessary to import projects.

To ensure the code produces valid data the corresponding tests check if
the produced rows are valid according to the model validation rules.
2017-11-07 23:24:59 +01:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Rémy Coutable e046e4c14d Namespace access token session key in `Import::GithubController`
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-19 17:35:51 +01:00
Rémy Coutable 103114e3d7 Rename Gogs to Gitea, DRY the controller and improve views
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-19 17:35:51 +01:00
James Lopez 0c65112da7 modify github import JS and controller so we can now specify a namespace and/or name for a project.
- Fixed and added specs.
- Added different namespace options depending on user privilages
- Updated docs.
2016-09-20 10:14:39 +02:00
Douglas Barbosa Alexandre 325de662ce Don't create groups for unallowed users when importing projects 2016-08-31 12:55:45 -03:00
Eric K Idema 12aa1f898d Import from Github using Personal Access Tokens.
This stands as an alternative to using OAuth to access a user's Github
repositories.  This is setup in such a way that it can be used without OAuth
configuration.

From a UI perspective, the how to import modal has been replaced by a full
page, which includes a form for posting a personal access token back to the
Import::GithubController.

If the user has logged in via GitHub, skip the Personal Access Token and go
directly to Github for an access token via OAuth.
2016-06-30 18:48:17 +02:00
Kamil Trzcinski a0adafddd0 Remove require_relative 'import_spec_helper' 2016-06-08 18:18:49 +02:00
Stan Hu eede032345 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.
2016-04-26 21:00:55 -07:00
Stan Hu 4ad64ab3f4 Fix duplicate repositories in GitHub import page
By default, all the current user's repositories are accessible via the
/users endpoint. There's no need to traverse all the organization
repositories as well.

See:

* http://www.rubydoc.info/github/pengwynn/octokit/Octokit/Client/Repositories#repositories-instance_method
* https://developer.github.com/v3/repos/#list-your-repositories

Closes #2523
2015-10-19 10:39:59 -07:00
Stan Hu ed1d4fa477 Remove user OAuth tokens stored in database for Bitbucket, GitHub, and GitLab
and request them each session. Pass these tokens to the project import data.

This prevents the need to encrypt these tokens and clear them in case they
expire or get revoked.

For example, if you deleted and re-created OAuth2 keys for Bitbucket, you would get
an Error 500 with no way to recover:

```
Started GET "/import/bitbucket/status" for x.x.x.x at 2015-08-07 05:24:10 +0000
Processing by Import::BitbucketController#status as HTML
Completed 500 Internal Server Error in 607ms (ActiveRecord: 2.3ms)

NameError (uninitialized constant Import::BitbucketController::Unauthorized):
  app/controllers/import/bitbucket_controller.rb:77:in `rescue in go_to_bitbucket_for_permissions'
  app/controllers/import/bitbucket_controller.rb:74:in `go_to_bitbucket_for_permissions'
  app/controllers/import/bitbucket_controller.rb:86:in `bitbucket_unauthorized'
```

Closes #1871
2015-08-23 09:23:44 -07:00
Dmitriy Zaporozhets f40b99d02e
Merge branch 'master' into rubocop-for-tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Conflicts:
	spec/features/issues_spec.rb
	spec/models/forked_project_link_spec.rb
	spec/models/hooks/service_hook_spec.rb
	spec/models/hooks/web_hook_spec.rb
	spec/models/project_services/hipchat_service_spec.rb
	spec/requests/api/project_members_spec.rb
	spec/requests/api/projects_spec.rb
	spec/requests/api/system_hooks_spec.rb
	spec/services/archive_repository_service_spec.rb
	spec/support/matchers.rb
	spec/tasks/gitlab/backup_rake_spec.rb
2015-06-23 10:44:03 +02:00
Robert Speicher 15a05be70d Fix Style/Blocks cop violations 2015-06-22 16:00:54 -04:00
Robert Speicher dad88568f3 Update and simplify Import controller specs 2015-06-22 12:13:46 +02:00
Douwe Maan d92e4ccc6e Add tests. 2015-04-01 17:17:18 +02:00
Douwe Maan 3175438f02 Fix missing GitHub organisation repositories on import page. 2015-03-12 13:47:15 +01:00
Douwe Maan f2b37de54b Fix specs. 2015-02-24 15:07:24 +01:00
Jeroen van Baarsen 026e988544 Even more hound fixes
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-12 21:00:55 +01:00
Jeroen van Baarsen 940a402b6e Fixed hound warnings
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-12 19:32:58 +01:00
Jeroen van Baarsen 0c4a70a306 Updated rspec to rspec 3.x syntax
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-12 19:17:35 +01:00
Valery Sizov b3c90dd514 GitHub importer refactoring 2015-02-05 21:48:21 -08:00
Valery Sizov 2d5765bd2c gitlab.com importer: fix specs after refactoring 2015-02-05 12:50:34 -08:00