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
Boxiang Sun
gitlab-ce
Commits
29c50c53
Commit
29c50c53
authored
Jun 29, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default Git access protocol to `web`
parent
fbaabb39
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
15 additions
and
21 deletions
+15
-21
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+3
-7
app/helpers/branches_helper.rb
app/helpers/branches_helper.rb
+1
-1
app/helpers/button_helper.rb
app/helpers/button_helper.rb
+4
-4
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
app/services/commits/change_service.rb
app/services/commits/change_service.rb
+1
-1
app/services/files/base_service.rb
app/services/files/base_service.rb
+1
-1
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+1
-3
lib/gitlab/protocol_access.rb
lib/gitlab/protocol_access.rb
+2
-2
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+1
-1
No files found.
app/helpers/application_settings_helper.rb
View file @
29c50c53
...
@@ -44,19 +44,15 @@ module ApplicationSettingsHelper
...
@@ -44,19 +44,15 @@ module ApplicationSettingsHelper
end
end
end
end
def
enabled_project_
tooltip
(
project
,
protocol
)
def
enabled_project_
button
(
project
,
protocol
)
case
protocol
case
protocol
when
'ssh'
when
'ssh'
s
anitize_clone_button
(
ssh_clone_button
(
project
,
'bottom'
)
)
s
sh_clone_button
(
project
,
'bottom'
,
false
)
else
else
sanitize_clone_button
(
http_clone_button
(
project
,
'bottom'
)
)
http_clone_button
(
project
,
'bottom'
,
false
)
end
end
end
end
def
sanitize_clone_button
(
input
)
sanitize
(
input
,
tags:
%w(a)
,
attributes:
%w(id class title data-html data-container data-placement data-title data-original-title aria-describedby)
)
end
# Return a group of checkboxes that use Bootstrap's button plugin for a
# Return a group of checkboxes that use Bootstrap's button plugin for a
# toggle button effect.
# toggle button effect.
def
restricted_level_checkboxes
(
help_block_id
)
def
restricted_level_checkboxes
(
help_block_id
)
...
...
app/helpers/branches_helper.rb
View file @
29c50c53
...
@@ -12,7 +12,7 @@ module BranchesHelper
...
@@ -12,7 +12,7 @@ module BranchesHelper
def
can_push_branch?
(
project
,
branch_name
)
def
can_push_branch?
(
project
,
branch_name
)
return
false
unless
project
.
repository
.
branch_exists?
(
branch_name
)
return
false
unless
project
.
repository
.
branch_exists?
(
branch_name
)
::
Gitlab
::
GitAccess
.
new
(
current_user
,
project
,
'web'
).
can_push_to_branch?
(
branch_name
)
::
Gitlab
::
GitAccess
.
new
(
current_user
,
project
).
can_push_to_branch?
(
branch_name
)
end
end
def
project_branches
def
project_branches
...
...
app/helpers/button_helper.rb
View file @
29c50c53
...
@@ -40,7 +40,7 @@ module ButtonHelper
...
@@ -40,7 +40,7 @@ module ButtonHelper
type: :button
type: :button
end
end
def
http_clone_button
(
project
,
placement
=
'right'
)
def
http_clone_button
(
project
,
placement
=
'right'
,
append_link
=
true
)
klass
=
'http-selector'
klass
=
'http-selector'
klass
<<
' has-tooltip'
if
current_user
.
try
(
:require_password?
)
klass
<<
' has-tooltip'
if
current_user
.
try
(
:require_password?
)
...
@@ -48,7 +48,7 @@ module ButtonHelper
...
@@ -48,7 +48,7 @@ module ButtonHelper
content_tag
:a
,
protocol
,
content_tag
:a
,
protocol
,
class:
klass
,
class:
klass
,
href:
project
.
http_url_to_repo
,
href:
(
project
.
http_url_to_repo
if
append_link
)
,
data:
{
data:
{
html:
true
,
html:
true
,
placement:
placement
,
placement:
placement
,
...
@@ -57,13 +57,13 @@ module ButtonHelper
...
@@ -57,13 +57,13 @@ module ButtonHelper
}
}
end
end
def
ssh_clone_button
(
project
,
placement
=
'right'
)
def
ssh_clone_button
(
project
,
placement
=
'right'
,
append_link
=
true
)
klass
=
'ssh-selector'
klass
=
'ssh-selector'
klass
<<
' has-tooltip'
if
current_user
.
try
(
:require_ssh_key?
)
klass
<<
' has-tooltip'
if
current_user
.
try
(
:require_ssh_key?
)
content_tag
:a
,
'SSH'
,
content_tag
:a
,
'SSH'
,
class:
klass
,
class:
klass
,
href:
project
.
ssh_url_to_repo
,
href:
(
project
.
ssh_url_to_repo
if
append_link
)
,
data:
{
data:
{
html:
true
,
html:
true
,
placement:
placement
,
placement:
placement
,
...
...
app/models/merge_request.rb
View file @
29c50c53
...
@@ -481,7 +481,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -481,7 +481,7 @@ class MergeRequest < ActiveRecord::Base
end
end
def
can_be_merged_by?
(
user
)
def
can_be_merged_by?
(
user
)
::
Gitlab
::
GitAccess
.
new
(
user
,
project
,
'web'
).
can_push_to_branch?
(
target_branch
)
::
Gitlab
::
GitAccess
.
new
(
user
,
project
).
can_push_to_branch?
(
target_branch
)
end
end
def
mergeable_ci_state?
def
mergeable_ci_state?
...
...
app/services/commits/change_service.rb
View file @
29c50c53
...
@@ -23,7 +23,7 @@ module Commits
...
@@ -23,7 +23,7 @@ module Commits
private
private
def
check_push_permissions
def
check_push_permissions
allowed
=
::
Gitlab
::
GitAccess
.
new
(
current_user
,
project
,
'web'
).
can_push_to_branch?
(
@target_branch
)
allowed
=
::
Gitlab
::
GitAccess
.
new
(
current_user
,
project
).
can_push_to_branch?
(
@target_branch
)
unless
allowed
unless
allowed
raise
ValidationError
.
new
(
'You are not allowed to push into this branch'
)
raise
ValidationError
.
new
(
'You are not allowed to push into this branch'
)
...
...
app/services/files/base_service.rb
View file @
29c50c53
...
@@ -43,7 +43,7 @@ module Files
...
@@ -43,7 +43,7 @@ module Files
end
end
def
validate
def
validate
allowed
=
::
Gitlab
::
GitAccess
.
new
(
current_user
,
project
,
'web'
).
can_push_to_branch?
(
@target_branch
)
allowed
=
::
Gitlab
::
GitAccess
.
new
(
current_user
,
project
).
can_push_to_branch?
(
@target_branch
)
unless
allowed
unless
allowed
raise_error
(
"You are not allowed to push into this branch"
)
raise_error
(
"You are not allowed to push into this branch"
)
...
...
lib/gitlab/git_access.rb
View file @
29c50c53
...
@@ -5,7 +5,7 @@ module Gitlab
...
@@ -5,7 +5,7 @@ module Gitlab
attr_reader
:actor
,
:project
,
:protocol
attr_reader
:actor
,
:project
,
:protocol
def
initialize
(
actor
,
project
,
protocol
)
def
initialize
(
actor
,
project
,
protocol
=
'web'
)
@actor
=
actor
@actor
=
actor
@project
=
project
@project
=
project
@protocol
=
protocol
@protocol
=
protocol
...
@@ -50,8 +50,6 @@ module Gitlab
...
@@ -50,8 +50,6 @@ module Gitlab
end
end
def
check
(
cmd
,
changes
=
nil
)
def
check
(
cmd
,
changes
=
nil
)
raise
'Access denied due to unspecified Git access protocol'
unless
protocol
.
present?
return
build_status_object
(
false
,
"Git access over
#{
protocol
.
upcase
}
is not allowed"
)
unless
protocol_allowed?
return
build_status_object
(
false
,
"Git access over
#{
protocol
.
upcase
}
is not allowed"
)
unless
protocol_allowed?
unless
actor
unless
actor
...
...
lib/gitlab/protocol_access.rb
View file @
29c50c53
module
Gitlab
module
Gitlab
module
ProtocolAccess
module
ProtocolAccess
def
self
.
allowed?
(
protocol
)
def
self
.
allowed?
(
protocol
)
if
protocol
.
to_s
==
'web'
if
protocol
==
'web'
true
true
elsif
current_application_settings
.
enabled_git_access_protocol
.
blank?
elsif
current_application_settings
.
enabled_git_access_protocol
.
blank?
true
true
else
else
protocol
.
to_s
==
current_application_settings
.
enabled_git_access_protocol
protocol
==
current_application_settings
.
enabled_git_access_protocol
end
end
end
end
end
end
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
29c50c53
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
GitAccess
,
lib:
true
do
describe
Gitlab
::
GitAccess
,
lib:
true
do
let
(
:access
)
{
Gitlab
::
GitAccess
.
new
(
actor
,
project
,
'web'
)
}
let
(
:access
)
{
Gitlab
::
GitAccess
.
new
(
actor
,
project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:actor
)
{
user
}
let
(
:actor
)
{
user
}
...
...
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