summaryrefslogtreecommitdiff
path: root/lib/api/internal.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/internal.rb')
-rw-r--r--lib/api/internal.rb24
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index 70d0d57204d..215bc03d0e9 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -11,14 +11,16 @@ module API
# Params:
# key_id - ssh key id for Git over SSH
# user_id - user id for Git over HTTP
+ # protocol - Git access protocol being used, e.g. HTTP or SSH
# project - project path with namespace
# action - git action (git-upload-pack or git-receive-pack)
- # ref - branch name
- # forced_push - forced_push
- # protocol - Git access protocol being used, e.g. HTTP or SSH
+ # changes - changes as "oldrev newrev ref", see Gitlab::ChangesList
post "/allowed" do
status 200
+ # Stores some Git-specific env thread-safely
+ Gitlab::Git::Env.set(parse_env)
+
actor =
if params[:key_id]
Key.find_by(id: params[:key_id])
@@ -30,18 +32,10 @@ module API
actor.update_last_used_at if actor.is_a?(Key)
- access =
- if wiki?
- Gitlab::GitAccessWiki.new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities)
- else
- Gitlab::GitAccess.new(actor,
- project,
- protocol,
- authentication_abilities: ssh_authentication_abilities,
- env: parse_allowed_environment_variables)
- end
-
- access_status = access.check(params[:action], params[:changes])
+ access_checker = wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess
+ access_status = access_checker
+ .new(actor, project, protocol, authentication_abilities: ssh_authentication_abilities)
+ .check(params[:action], params[:changes])
response = { status: access_status.status, message: access_status.message }