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
284b6e69
Commit
284b6e69
authored
Nov 16, 2017
by
James Lopez
Committed by
Nick Thomas
Nov 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add warning when Geo is configured insecurely
parent
a7046b5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
2 deletions
+47
-2
changelogs/unreleased-ee/feature-http-geo-warning.yml
changelogs/unreleased-ee/feature-http-geo-warning.yml
+5
-0
ee/app/controllers/admin/geo_nodes_controller.rb
ee/app/controllers/admin/geo_nodes_controller.rb
+16
-1
spec/controllers/admin/geo_nodes_controller_spec.rb
spec/controllers/admin/geo_nodes_controller_spec.rb
+26
-1
No files found.
changelogs/unreleased-ee/feature-http-geo-warning.yml
0 → 100644
View file @
284b6e69
---
title
:
Add warning when Geo is configured insecurely
merge_request
:
3368
author
:
type
:
added
ee/app/controllers/admin/geo_nodes_controller.rb
View file @
284b6e69
class
Admin::GeoNodesController
<
Admin
::
ApplicationController
before_action
:check_license
,
except:
[
:index
,
:destroy
]
before_action
:load_node
,
only:
[
:edit
,
:update
,
:destroy
,
:repair
,
:toggle
,
:status
]
before_action
:check_insecure_nodes
helper
EE
::
GeoHelper
...
...
@@ -9,7 +10,7 @@ class Admin::GeoNodesController < Admin::ApplicationController
@node
=
GeoNode
.
new
unless
Gitlab
::
Geo
.
license_allows?
flash
.
now
[
:alert
]
=
'You need a different license to enable Geo replication'
flash
_now
(
:alert
,
'You need a different license to enable Geo replication'
)
end
end
...
...
@@ -101,4 +102,18 @@ class Admin::GeoNodesController < Admin::ApplicationController
def
load_node
@node
=
GeoNode
.
find
(
params
[
:id
])
end
def
check_insecure_nodes
if
has_insecure_nodes?
flash_now
(
:alert
,
'You have configured Geo nodes using an insecure HTTP connection. We recommend the use of HTTPS.'
)
end
end
def
has_insecure_nodes?
GeoNode
.
where
(
schema:
'http'
).
any?
end
def
flash_now
(
type
,
message
)
flash
.
now
[
type
]
=
flash
.
now
[
type
].
blank?
?
message
:
"
#{
flash
.
now
[
type
]
}
<BR>
#{
message
}
"
.
html_safe
end
end
spec/controllers/admin/geo_nodes_controller_spec.rb
View file @
284b6e69
...
...
@@ -46,7 +46,8 @@ describe Admin::GeoNodesController, :postgresql do
it
'displays a flash message'
do
go
expect
(
controller
).
to
set_flash
.
now
[
:alert
].
to
(
'You need a different license to enable Geo replication'
)
expect
(
flash
[
:alert
]).
to
include
(
'You need a different license to enable Geo replication'
)
end
it
'does not redirects to the license page'
do
...
...
@@ -54,6 +55,30 @@ describe Admin::GeoNodesController, :postgresql do
expect
(
response
).
not_to
redirect_to
(
admin_license_path
)
end
end
context
'Secured URL'
do
let
(
:alert_message
)
{
'You have configured Geo nodes using an insecure HTTP connection. We recommend the use of HTTPS.'
}
context
'HTTP nodes'
do
it
'displays a flash message'
do
create
(
:geo_node
,
url:
'http://not.safe'
)
go
expect
(
flash
[
:alert
]).
to
include
(
alert_message
)
end
end
context
'with HTTPS nodes'
do
it
'does not display a flash message'
do
create
(
:geo_node
,
url:
'https://much.safer'
)
go
expect
(
flash
[
:alert
]).
not_to
include
(
alert_message
)
end
end
end
end
describe
'#destroy'
do
...
...
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