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
iv
gitlab-ce
Commits
83e83b66
Commit
83e83b66
authored
Mar 20, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve grack auth
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
612a909e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
32 deletions
+17
-32
lib/gitlab/backend/grack_auth.rb
lib/gitlab/backend/grack_auth.rb
+17
-4
lib/gitlab/backend/grack_helpers.rb
lib/gitlab/backend/grack_helpers.rb
+0
-28
No files found.
lib/gitlab/backend/grack_auth.rb
View file @
83e83b66
require_relative
'shell_env'
require_relative
'grack_helpers'
module
Grack
class
Auth
<
Rack
::
Auth
::
Basic
include
Helpers
attr_accessor
:user
,
:project
,
:env
...
...
@@ -79,12 +77,14 @@ module Grack
def
authorize_request
(
service
)
case
service
when
'git-upload-pack'
when
*
Gitlab
::
GitAccess
::
DOWNLOAD_COMMANDS
# Serve only upload request.
# Authorization on push will be serverd by update hook in repository
Gitlab
::
GitAccess
.
new
.
download_allowed?
(
user
,
project
)
else
when
*
Gitlab
::
GitAccess
::
PUSH_COMMANDS
true
else
false
end
end
...
...
@@ -101,5 +101,18 @@ module Grack
def
project
@project
||=
project_by_path
(
@request
.
path_info
)
end
def
project_by_path
(
path
)
if
m
=
/^([\w\.\/-]+)\.git/
.
match
(
path
).
to_a
path_with_namespace
=
m
.
last
path_with_namespace
.
gsub!
(
/\.wiki$/
,
''
)
Project
.
find_with_namespace
(
path_with_namespace
)
end
end
def
render_not_found
[
404
,
{
"Content-Type"
=>
"text/plain"
},
[
"Not Found"
]]
end
end
end
lib/gitlab/backend/grack_helpers.rb
deleted
100644 → 0
View file @
612a909e
module
Grack
module
Helpers
def
project_by_path
(
path
)
if
m
=
/^([\w\.\/-]+)\.git/
.
match
(
path
).
to_a
path_with_namespace
=
m
.
last
path_with_namespace
.
gsub!
(
/\.wiki$/
,
''
)
Project
.
find_with_namespace
(
path_with_namespace
)
end
end
def
render_not_found
[
404
,
{
"Content-Type"
=>
"text/plain"
},
[
"Not Found"
]]
end
def
can?
(
object
,
action
,
subject
)
abilities
.
allowed?
(
object
,
action
,
subject
)
end
def
abilities
@abilities
||=
begin
abilities
=
Six
.
new
abilities
<<
Ability
abilities
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