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
b632c8a9
Commit
b632c8a9
authored
Jan 31, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disallow all post requests on Geo node, except logout
parent
d2716cde
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
lib/gitlab/middleware/readonly_geo.rb
lib/gitlab/middleware/readonly_geo.rb
+12
-5
No files found.
lib/gitlab/middleware/readonly_geo.rb
View file @
b632c8a9
module
Gitlab
module
Middleware
class
ReadonlyGeo
DISALLOWED_METHODS
=
%w(PATCH PUT DELETE)
DISALLOWED_METHODS
=
%w(P
OST P
ATCH PUT DELETE)
def
initialize
(
app
)
@app
=
app
...
...
@@ -16,7 +16,7 @@ module Gitlab
rack_flash
.
alert
=
'You cannot do writing operations on a readonly Gitlab Geo instance'
rack_session
[
'flash'
]
=
rack_flash
.
to_session_value
return
[
301
,
{
'Location'
=>
last_visited_url
},
[]
]
return
[
301
,
{
'Location'
=>
last_visited_url
},
[]
]
end
@app
.
call
(
env
)
...
...
@@ -25,7 +25,7 @@ module Gitlab
private
def
disallowed_request?
DISALLOWED_METHODS
.
include?
(
@env
[
'REQUEST_METHOD'
])
DISALLOWED_METHODS
.
include?
(
@env
[
'REQUEST_METHOD'
])
&&
!
logout_route
end
def
rack_flash
...
...
@@ -41,8 +41,15 @@ module Gitlab
end
def
last_visited_url
Rails
.
logger
.
debug
(
"SESSION:
#{
rack_session
.
inspect
}
"
)
@env
[
'HTTP_REFERER'
]
||
rack_session
[
'user_return_to'
]
||
Rails
.
application
.
routes
.
url_helpers
.
root_url
@env
[
'HTTP_REFERER'
]
||
rack_session
[
'user_return_to'
]
||
@app
.
url_helpers
.
root_url
end
def
route_hash
@route_hash
||=
Rails
.
application
.
routes
.
recognize_path
(
request
.
url
,
{
method:
request
.
request_method
})
rescue
{}
end
def
logout_route
route_hash
[
:controller
]
==
'sessions'
&&
route_hash
[
:action
]
==
'destroy'
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