diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 04:43:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-24 04:43:31 +0300 |
commit | e20a1cde5d740fbc9f4d033786a8cd5ad7eb8b4d (patch) | |
tree | cf76b0527f1909eaf1ecac057a4ccc7591cce4f6 /lib/api/internal/base.rb | |
parent | 5fc725def41e6973e92bc32095774edd60fd154f (diff) |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'lib/api/internal/base.rb')
-rw-r--r-- | lib/api/internal/base.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb index f1e33b27d2b..0d50a310b37 100644 --- a/lib/api/internal/base.rb +++ b/lib/api/internal/base.rb @@ -43,12 +43,9 @@ module API Gitlab::Git::HookEnv.set(gl_repository, env) if container actor.update_last_used_at! - access_checker = access_checker_for(actor, params[:protocol]) check_result = begin - result = access_checker.check(params[:action], params[:changes]) - @project ||= access_checker.project - result + access_check!(actor, params) rescue Gitlab::GitAccess::ForbiddenError => e # The return code needs to be 401. If we return 403 # the custom message we return won't be shown to the user @@ -92,6 +89,17 @@ module API response_with_status(code: 500, success: false, message: UNKNOWN_CHECK_RESULT_ERROR) end end + + def access_check!(actor, params) + access_checker = access_checker_for(actor, params[:protocol]) + access_checker.check(params[:action], params[:changes]).tap do |result| + break result if @project || !repo_type.project? + + # If we have created a project directly from a git push + # we have to assign its value to both @project and @container + @project = @container = access_checker.project + end + end end namespace 'internal' do |