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
8db947bc
Commit
8db947bc
authored
Jun 29, 2012
by
Saito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implements protected branches to smart http protocal
parent
7f44599e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
config/initializers/grack_auth.rb
config/initializers/grack_auth.rb
+19
-4
No files found.
config/initializers/grack_auth.rb
View file @
8db947bc
...
...
@@ -18,14 +18,29 @@ module Grack
elsif
@env
[
'REQUEST_METHOD'
]
==
'POST'
if
@env
[
'REQUEST_URI'
].
end_with?
(
'git-upload-pack'
)
return
project
.
dev_access_for?
(
user
)
elsif
@env
[
'REQUEST_URI'
].
end_with?
(
'git-upload-pack'
)
#TODO master branch protection
return
project
.
dev_access_for?
(
user
)
elsif
@env
[
'REQUEST_URI'
].
end_with?
(
'git-receive-pack'
)
if
project
.
protected_branches
.
map
(
&
:name
).
include?
(
current_ref
)
project
.
master_access_for?
(
user
)
else
project
.
dev_access_for?
(
user
)
end
else
false
end
else
false
end
end
# valid?
def
current_ref
if
@env
[
"HTTP_CONTENT_ENCODING"
]
=~
/gzip/
input
=
Zlib
::
GzipReader
.
new
(
@request
.
body
).
string
else
input
=
@request
.
body
.
string
end
oldrev
,
newrev
,
ref
=
input
.
split
(
' '
)
/refs\/heads\/([\w-]+)/
.
match
(
ref
).
to_a
.
last
end
end
# Auth
end
# Grack
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