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
2742f9fb
Commit
2742f9fb
authored
Sep 16, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve authentication_result usage
parent
b0195d5c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
13 deletions
+20
-13
app/controllers/projects/git_http_client_controller.rb
app/controllers/projects/git_http_client_controller.rb
+18
-11
spec/requests/git_http_spec.rb
spec/requests/git_http_spec.rb
+2
-2
No files found.
app/controllers/projects/git_http_client_controller.rb
View file @
2742f9fb
...
@@ -19,6 +19,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController
...
@@ -19,6 +19,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController
private
private
def
authenticate_user
def
authenticate_user
@authentication_result
=
Gitlab
::
Auth
::
Result
.
new
if
project
&&
project
.
public?
&&
download_request?
if
project
&&
project
.
public?
&&
download_request?
return
# Allow access
return
# Allow access
end
end
...
@@ -124,6 +126,18 @@ class Projects::GitHttpClientController < Projects::ApplicationController
...
@@ -124,6 +126,18 @@ class Projects::GitHttpClientController < Projects::ApplicationController
end
end
end
end
def
ci?
authentication_result
.
ci?
&&
authentication_project
&&
authentication_project
==
project
end
def
lfs_deploy_key?
authentication_result
.
lfs_deploy_token?
&&
actor
&&
actor
.
projects
.
include?
(
project
)
end
def
authentication_has_download_access?
def
authentication_has_download_access?
has_authentication_ability?
(
:download_code
)
||
has_authentication_ability?
(
:build_download_code
)
has_authentication_ability?
(
:download_code
)
||
has_authentication_ability?
(
:build_download_code
)
end
end
...
@@ -132,19 +146,12 @@ class Projects::GitHttpClientController < Projects::ApplicationController
...
@@ -132,19 +146,12 @@ class Projects::GitHttpClientController < Projects::ApplicationController
has_authentication_ability?
(
:push_code
)
has_authentication_ability?
(
:push_code
)
end
end
def
ci?
def
has_authentication_ability?
(
capability
)
authentication_result
&&
authentication_result
.
ci?
&&
(
authentication_abilities
||
[]).
include?
(
capability
)
authentication_result
.
project
&&
authentication_result
.
project
==
project
end
def
lfs_deploy_key?
authentication_result
&&
authentication_result
.
lfs_deploy_token?
&&
actor
&&
actor
.
projects
.
include?
(
project
)
end
end
def
has_authentication_ability?
(
capability
)
def
authentication_project
authentication_abilities
&&
authentication_result
.
project
authentication_abilities
.
include?
(
capability
)
end
end
def
verify_workhorse_api!
def
verify_workhorse_api!
...
...
spec/requests/git_http_spec.rb
View file @
2742f9fb
...
@@ -322,10 +322,10 @@ describe 'Git HTTP requests', lib: true do
...
@@ -322,10 +322,10 @@ describe 'Git HTTP requests', lib: true do
expect
(
response
).
to
have_http_status
(
401
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
it
"downloads from other project get status 40
1
"
do
it
"downloads from other project get status 40
4
"
do
clone_get
"
#{
other_project
.
path_with_namespace
}
.git"
,
user:
'gitlab-ci-token'
,
password:
build
.
token
clone_get
"
#{
other_project
.
path_with_namespace
}
.git"
,
user:
'gitlab-ci-token'
,
password:
build
.
token
expect
(
response
).
to
have_http_status
(
40
1
)
expect
(
response
).
to
have_http_status
(
40
4
)
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