diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 11:59:07 +0000 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/api/helpers | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) | |
download | gitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/api/helpers')
-rw-r--r-- | lib/api/helpers/internal_helpers.rb | 34 | ||||
-rw-r--r-- | lib/api/helpers/members_helpers.rb | 2 | ||||
-rw-r--r-- | lib/api/helpers/packages/basic_auth_helpers.rb | 4 | ||||
-rw-r--r-- | lib/api/helpers/packages/conan/api_helpers.rb | 13 | ||||
-rw-r--r-- | lib/api/helpers/projects_helpers.rb | 4 | ||||
-rw-r--r-- | lib/api/helpers/services_helpers.rb | 61 | ||||
-rw-r--r-- | lib/api/helpers/sse_helpers.rb | 16 |
7 files changed, 112 insertions, 22 deletions
diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb index 69b53ea6c2f..12b0a053e79 100644 --- a/lib/api/helpers/internal_helpers.rb +++ b/lib/api/helpers/internal_helpers.rb @@ -31,8 +31,7 @@ module API def access_checker_for(actor, protocol) access_checker_klass.new(actor.key_or_user, container, protocol, authentication_abilities: ssh_authentication_abilities, - namespace_path: namespace_path, - repository_path: project_path, + repository_path: repository_path, redirected_path: redirected_path) end @@ -71,18 +70,22 @@ module API false end - def project_path - project&.path || project_path_match[:project_path] - end - - def namespace_path - project&.namespace&.full_path || project_path_match[:namespace_path] - end - private - def project_path_match - @project_path_match ||= params[:project].match(Gitlab::PathRegex.full_project_git_path_regex) || {} + def repository_path + if container + "#{container.full_path}.git" + elsif params[:project] + # When the project doesn't exist, we still need to pass on the path + # to support auto-creation in `GitAccessProject`. + # + # For consistency with the Git HTTP controllers, we normalize the path + # to remove a leading slash and ensure a trailing `.git`. + # + # NOTE: For GitLab Shell, `params[:project]` is the full repository path + # from the SSH command, with an optional trailing `.git`. + "#{params[:project].delete_prefix('/').delete_suffix('.git')}.git" + end end # rubocop:disable Gitlab/ModuleWithInstanceVariables @@ -96,7 +99,7 @@ module API end # rubocop:enable Gitlab/ModuleWithInstanceVariables - # Project id to pass between components that don't share/don't have + # Repository id to pass between components that don't share/don't have # access to the same filesystem mounts def gl_repository repo_type.identifier_for_container(container) @@ -106,8 +109,9 @@ module API repository.full_path end - # Return the repository depending on whether we want the wiki or the - # regular repository + # Return the repository for the detected type and container + # + # @returns [Repository] def repository @repository ||= repo_type.repository_for(container) end diff --git a/lib/api/helpers/members_helpers.rb b/lib/api/helpers/members_helpers.rb index 431001c227d..8aed578905e 100644 --- a/lib/api/helpers/members_helpers.rb +++ b/lib/api/helpers/members_helpers.rb @@ -45,7 +45,7 @@ module API end def find_all_members_for_project(project) - MembersFinder.new(project, current_user).execute(include_relations: [:inherited, :direct, :invited_groups_members]) + MembersFinder.new(project, current_user).execute(include_relations: [:inherited, :direct, :invited_groups]) end def find_all_members_for_group(group) diff --git a/lib/api/helpers/packages/basic_auth_helpers.rb b/lib/api/helpers/packages/basic_auth_helpers.rb index e35a8712131..0784efc11d6 100644 --- a/lib/api/helpers/packages/basic_auth_helpers.rb +++ b/lib/api/helpers/packages/basic_auth_helpers.rb @@ -7,8 +7,8 @@ module API extend ::Gitlab::Utils::Override module Constants - AUTHENTICATE_REALM_HEADER = 'Www-Authenticate: Basic realm' - AUTHENTICATE_REALM_NAME = 'GitLab Packages Registry' + AUTHENTICATE_REALM_HEADER = 'WWW-Authenticate' + AUTHENTICATE_REALM_NAME = 'Basic realm="GitLab Packages Registry"' end include Constants diff --git a/lib/api/helpers/packages/conan/api_helpers.rb b/lib/api/helpers/packages/conan/api_helpers.rb index 934e18bdd0a..39ecfc171a9 100644 --- a/lib/api/helpers/packages/conan/api_helpers.rb +++ b/lib/api/helpers/packages/conan/api_helpers.rb @@ -164,7 +164,11 @@ module API end def find_or_create_package - package || ::Packages::Conan::CreatePackageService.new(project, current_user, params).execute + package || ::Packages::Conan::CreatePackageService.new( + project, + current_user, + params.merge(build: current_authenticated_job) + ).execute end def track_push_package_event @@ -184,7 +188,11 @@ module API def create_package_file_with_type(file_type, current_package) unless params[:file].size == 0 # rubocop: disable Style/ZeroLengthPredicate # conan sends two upload requests, the first has no file, so we skip record creation if file.size == 0 - ::Packages::Conan::CreatePackageFileService.new(current_package, params[:file], params.merge(conan_file_type: file_type)).execute + ::Packages::Conan::CreatePackageFileService.new( + current_package, + params[:file], + params.merge(conan_file_type: file_type, build: current_authenticated_job) + ).execute end end @@ -214,6 +222,7 @@ module API return unless route_authentication_setting[:job_token_allowed] job = find_job_from_token || raise(::Gitlab::Auth::UnauthorizedError) + @current_authenticated_job = job # rubocop:disable Gitlab/ModuleWithInstanceVariables job.user end diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb index 0364ba2ad9e..f5f45cf7351 100644 --- a/lib/api/helpers/projects_helpers.rb +++ b/lib/api/helpers/projects_helpers.rb @@ -6,7 +6,7 @@ module API extend ActiveSupport::Concern extend Grape::API::Helpers - STATISTICS_SORT_PARAMS = %w[storage_size repository_size wiki_size].freeze + STATISTICS_SORT_PARAMS = %w[storage_size repository_size wiki_size packages_size].freeze params :optional_project_params_ce do optional :description, type: String, desc: 'The description of the project' @@ -32,6 +32,8 @@ module API optional :builds_access_level, type: String, values: %w(disabled private enabled), desc: 'Builds access level. One of `disabled`, `private` or `enabled`' optional :snippets_access_level, type: String, values: %w(disabled private enabled), desc: 'Snippets access level. One of `disabled`, `private` or `enabled`' optional :pages_access_level, type: String, values: %w(disabled private enabled public), desc: 'Pages access level. One of `disabled`, `private`, `enabled` or `public`' + optional :operations_access_level, type: String, values: %w(disabled private enabled), desc: 'Operations access level. One of `disabled`, `private` or `enabled`' + optional :analytics_access_level, type: String, values: %w(disabled private enabled), desc: 'Analytics access level. One of `disabled`, `private` or `enabled`' optional :emails_disabled, type: Boolean, desc: 'Disable email notifications' optional :show_default_award_emojis, type: Boolean, desc: 'Show default award emojis' diff --git a/lib/api/helpers/services_helpers.rb b/lib/api/helpers/services_helpers.rb index 4adb27a7414..9d2fd9978d9 100644 --- a/lib/api/helpers/services_helpers.rb +++ b/lib/api/helpers/services_helpers.rb @@ -304,6 +304,38 @@ module API desc: 'Project URL' } ], + 'datadog' => [ + { + required: true, + name: :api_key, + type: String, + desc: 'API key used for authentication with Datadog' + }, + { + required: false, + name: :datadog_site, + type: String, + desc: 'Choose the Datadog site to send data to. Set to "datadoghq.eu" to send data to the EU site' + }, + { + required: false, + name: :api_url, + type: String, + desc: '(Advanced) Define the full URL for your Datadog site directly' + }, + { + required: false, + name: :datadog_service, + type: String, + desc: 'Name of this GitLab instance that all data will be tagged with' + }, + { + required: false, + name: :datadog_env, + type: String, + desc: 'The environment tag that traces will be tagged with' + } + ], 'discord' => [ { required: true, @@ -459,6 +491,32 @@ module API desc: 'Colorize messages' } ], + 'jenkins' => [ + { + required: true, + name: :jenkins_url, + type: String, + desc: 'Jenkins root URL like https://jenkins.example.com' + }, + { + required: true, + name: :project_name, + type: String, + desc: 'The URL-friendly project name. Example: my_project_name' + }, + { + required: false, + name: :username, + type: String, + desc: 'A user with access to the Jenkins server, if applicable' + }, + { + required: false, + name: :password, + type: String, + desc: 'The password of the user' + } + ], 'jira' => [ { required: true, @@ -758,6 +816,7 @@ module API ::ConfluenceService, ::CampfireService, ::CustomIssueTrackerService, + ::DatadogService, ::DiscordService, ::DroneCiService, ::EmailsOnPushService, @@ -767,6 +826,7 @@ module API ::HangoutsChatService, ::HipchatService, ::IrkerService, + ::JenkinsService, ::JiraService, ::MattermostSlashCommandsService, ::SlackSlashCommandsService, @@ -787,7 +847,6 @@ module API def self.development_service_classes [ ::MockCiService, - ::MockDeploymentService, ::MockMonitoringService ] end diff --git a/lib/api/helpers/sse_helpers.rb b/lib/api/helpers/sse_helpers.rb new file mode 100644 index 00000000000..c354694f508 --- /dev/null +++ b/lib/api/helpers/sse_helpers.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module API + module Helpers + module SSEHelpers + def request_from_sse?(project) + return false if request.referer.blank? + + uri = URI.parse(request.referer) + uri.path.starts_with?(::Gitlab::Routing.url_helpers.project_root_sse_path(project)) + rescue URI::InvalidURIError + false + end + end + end +end |