BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
68fd66c6
Commit
68fd66c6
authored
Aug 28, 2014
by
Job van der Voort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block visibility level restriction override in controller
parent
d4180875
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
visibility_level.rb
lib/gitlab/visibility_level.rb
+15
-1
update_service_spec.rb
spec/services/projects/update_service_spec.rb
+1
-1
No files found.
lib/gitlab/visibility_level.rb
View file @
68fd66c6
...
...
@@ -23,7 +23,21 @@ module Gitlab
end
def
allowed_for?
(
user
,
level
)
user
.
is_admin?
||
!
Gitlab
.
config
.
gitlab
.
restricted_visibility_levels
.
include?
(
level
)
user
.
is_admin?
||
allowed_level?
(
level
)
end
# Level can be a string `"public"` or a value `20`, first check if valid,
# then check if the corresponding string appears in the config
def
allowed_level?
(
level
)
if
options
.
has_key?
(
level
.
to_s
)
non_restricted_level?
(
level
)
elsif
options
.
has_value?
(
level
.
to_i
)
non_restricted_level?
(
options
.
key
(
level
.
to_i
).
downcase
)
end
end
def
non_restricted_level?
(
level
)
!
Gitlab
.
config
.
gitlab
.
restricted_visibility_levels
.
include?
(
level
)
end
end
...
...
spec/services/projects/update_service_spec.rb
View file @
68fd66c6
...
...
@@ -48,7 +48,7 @@ describe Projects::UpdateService do
context
'respect configured visibility restrictions setting'
do
before
(
:each
)
do
@restrictions
=
double
(
"restrictions"
)
@restrictions
.
stub
(
:restricted_visibility_levels
)
{
[
Gitlab
::
VisibilityLevel
::
PUBLIC
]
}
@restrictions
.
stub
(
:restricted_visibility_levels
)
{
[
"public"
]
}
Settings
.
stub_chain
(
:gitlab
).
and_return
(
@restrictions
)
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