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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
aeaef0ad
Commit
aeaef0ad
authored
Feb 17, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support v4 API for GitLab Geo endpoints
parent
904981f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
changelogs/unreleased-ee/geo-apiv4-fix.yml
changelogs/unreleased-ee/geo-apiv4-fix.yml
+4
-0
lib/gitlab/middleware/readonly_geo.rb
lib/gitlab/middleware/readonly_geo.rb
+12
-2
spec/lib/gitlab/middleware/readonly_geo_spec.rb
spec/lib/gitlab/middleware/readonly_geo_spec.rb
+14
-0
No files found.
changelogs/unreleased-ee/geo-apiv4-fix.yml
0 → 100644
View file @
aeaef0ad
---
title
:
Support v4 API for GitLab Geo endpoints
merge_request
:
author
:
lib/gitlab/middleware/readonly_geo.rb
View file @
aeaef0ad
...
...
@@ -2,11 +2,12 @@ module Gitlab
module
Middleware
class
ReadonlyGeo
DISALLOWED_METHODS
=
%w(POST PATCH PUT DELETE)
WHITELISTED
=
%w(api/v3/internal api/v3/geo/refresh_wikis api/v3/geo/receive_events)
APPLICATION_JSON
=
'application/json'
API_VERSIONS
=
(
3
..
4
)
def
initialize
(
app
)
@app
=
app
@whitelisted
=
internal_routes
+
geo_routes
end
def
call
(
env
)
...
...
@@ -31,6 +32,15 @@ module Gitlab
private
def
internal_routes
API_VERSIONS
.
flat_map
{
|
version
|
"api/v
#{
version
}
/internal"
}
end
def
geo_routes
geo_routes
=
[
'refresh_wikis'
,
'receive_events'
]
API_VERSIONS
.
flat_map
{
|
version
|
geo_routes
.
map
{
|
route
|
"api/v
#{
version
}
/geo/
#{
route
}
"
}
}
end
def
disallowed_request?
DISALLOWED_METHODS
.
include?
(
@env
[
'REQUEST_METHOD'
])
&&
!
whitelisted_routes
end
...
...
@@ -60,7 +70,7 @@ module Gitlab
end
def
whitelisted_routes
logout_route
||
grack_route
||
WHITELISTED
.
any?
{
|
path
|
@
request
.
path
.
include?
(
path
)
}
||
sidekiq_route
logout_route
||
grack_route
||
@whitelisted
.
any?
{
|
path
|
request
.
path
.
include?
(
path
)
}
||
sidekiq_route
end
def
logout_route
...
...
spec/lib/gitlab/middleware/readonly_geo_spec.rb
View file @
aeaef0ad
...
...
@@ -76,6 +76,20 @@ describe Gitlab::Middleware::ReadonlyGeo, lib: true do
expect
(
response
).
not_to
be_a_redirect
expect
(
subject
).
not_to
disallow_request
end
it
'expects a POST internal request to be allowed'
do
response
=
request
.
post
(
"/api/
#{
API
::
API
.
version
}
/internal"
)
expect
(
response
).
not_to
be_a_redirect
expect
(
subject
).
not_to
disallow_request
end
it
'expects a POST Geo request to be allowed'
do
response
=
request
.
post
(
"/api/
#{
API
::
API
.
version
}
/geo/refresh_wikis"
)
expect
(
response
).
not_to
be_a_redirect
expect
(
subject
).
not_to
disallow_request
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