Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
729b358f
Commit
729b358f
authored
Mar 19, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push via http now served via /allowed API
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
f18a714f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
42 deletions
+5
-42
lib/gitlab/backend/grack_auth.rb
lib/gitlab/backend/grack_auth.rb
+5
-42
No files found.
lib/gitlab/backend/grack_auth.rb
View file @
729b358f
...
...
@@ -5,7 +5,7 @@ module Grack
class
Auth
<
Rack
::
Auth
::
Basic
include
Helpers
attr_accessor
:user
,
:project
,
:
ref
,
:
env
attr_accessor
:user
,
:project
,
:env
def
call
(
env
)
@env
=
env
...
...
@@ -80,24 +80,11 @@ module Grack
def
authorize_request
(
service
)
case
service
when
'git-upload-pack'
can?
(
user
,
:download_code
,
project
)
when
'git-receive-pack'
refs
.
each
do
|
ref
|
action
=
if
project
.
protected_branch?
(
ref
)
:push_code_to_protected_branches
else
:push_code
end
return
false
unless
can?
(
user
,
action
,
project
)
end
# Never let git-receive-pack trough unauthenticated; it's
# harmless but git < 1.8 doesn't like it
return
false
if
user
.
nil?
true
# Serve only upload request.
# Authorization on push will be serverd by update hook in repository
Gitlab
::
GitAccess
.
new
.
download_allowed?
(
user
,
project
)
else
fals
e
tru
e
end
end
...
...
@@ -114,29 +101,5 @@ module Grack
def
project
@project
||=
project_by_path
(
@request
.
path_info
)
end
def
refs
@refs
||=
parse_refs
end
def
parse_refs
input
=
if
@env
[
"HTTP_CONTENT_ENCODING"
]
=~
/gzip/
Zlib
::
GzipReader
.
new
(
@request
.
body
).
read
else
@request
.
body
.
read
end
# Need to reset seek point
@request
.
body
.
rewind
# Parse refs
refs
=
input
.
force_encoding
(
'ascii-8bit'
).
scan
(
/refs\/heads\/([\/\w\.-]+)/n
).
flatten
.
compact
# Cleanup grabare from refs
# if push to multiple branches
refs
.
map
do
|
ref
|
ref
.
gsub
(
/00.*/
,
""
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment