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
Léo-Paul Géneau
gitlab-ce
Commits
4dbfa14e
Commit
4dbfa14e
authored
Jun 23, 2017
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement review comments from @dbalexandre for !12300.
parent
1b8223dd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
22 deletions
+18
-22
lib/api/api_guard.rb
lib/api/api_guard.rb
+5
-7
lib/api/helpers.rb
lib/api/helpers.rb
+2
-2
spec/services/access_token_validation_service_spec.rb
spec/services/access_token_validation_service_spec.rb
+11
-13
No files found.
lib/api/api_guard.rb
View file @
4dbfa14e
...
...
@@ -30,15 +30,13 @@ module API
# endpoint class. If this method is called multiple times on the same class,
# the scopes are all aggregated.
def
allow_access_with_scope
(
scopes
,
options
=
{})
@scopes
||=
[]
params
=
Array
.
wrap
(
scopes
).
map
{
|
scope
|
{
name:
scope
,
if:
options
[
:if
]
}
}
@scopes
.
concat
(
params
)
Array
(
scopes
).
each
do
|
scope
|
allowed_scopes
<<
{
name:
scope
,
if:
options
[
:if
]
}
end
end
def
scopes
@scopes
def
allowed_
scopes
@scopes
||=
[]
end
end
...
...
lib/api/helpers.rb
View file @
4dbfa14e
...
...
@@ -416,8 +416,8 @@ module API
begin
endpoint_classes
=
[
options
[
:for
].
presence
,
::
API
::
API
].
compact
endpoint_classes
.
reduce
([])
do
|
memo
,
endpoint
|
if
endpoint
.
respond_to?
(
:scopes
)
memo
.
concat
(
endpoint
.
scopes
)
if
endpoint
.
respond_to?
(
:
allowed_
scopes
)
memo
.
concat
(
endpoint
.
allowed_
scopes
)
else
memo
end
...
...
spec/services/access_token_validation_service_spec.rb
View file @
4dbfa14e
...
...
@@ -41,7 +41,6 @@ describe AccessTokenValidationService, services: true do
end
context
"conditions"
do
context
"if"
do
it
"ignores any scopes whose `if` condition returns false"
do
token
=
double
(
"token"
,
scopes:
[
:api
,
:read_user
])
...
...
@@ -61,5 +60,4 @@ describe AccessTokenValidationService, services: true do
end
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