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
3148355c
Commit
3148355c
authored
May 03, 2018
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse `InternalRedirect` for the `EE::SessionsController`
parent
73a97a67
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
12 deletions
+39
-12
app/controllers/concerns/internal_redirect.rb
app/controllers/concerns/internal_redirect.rb
+1
-0
ee/app/controllers/concerns/ee/internal_redirect.rb
ee/app/controllers/concerns/ee/internal_redirect.rb
+16
-0
ee/app/controllers/ee/sessions_controller.rb
ee/app/controllers/ee/sessions_controller.rb
+0
-12
ee/spec/controllers/concerns/internal_redirect_spec.rb
ee/spec/controllers/concerns/internal_redirect_spec.rb
+22
-0
No files found.
app/controllers/concerns/internal_redirect.rb
View file @
3148355c
module
InternalRedirect
prepend
EE
::
InternalRedirect
extend
ActiveSupport
::
Concern
def
safe_redirect_path
(
path
)
...
...
ee/app/controllers/concerns/ee/internal_redirect.rb
0 → 100644
View file @
3148355c
module
EE
module
InternalRedirect
extend
::
Gitlab
::
Utils
::
Override
override
:host_allowed?
def
host_allowed?
(
uri
)
return
true
if
super
# Redirect is not only allowed to current host, but also to other Geo
# nodes. relative_url_root *must* be ignored here as we don't know what
# is root and what is path
truncated
=
uri
.
dup
.
tap
{
|
uri
|
uri
.
path
=
'/'
}
::
GeoNode
.
with_url_prefix
(
truncated
).
exists?
end
end
end
ee/app/controllers/ee/sessions_controller.rb
View file @
3148355c
...
...
@@ -36,17 +36,5 @@ module EE
super
end
override
:redirect_allowed_to?
def
redirect_allowed_to?
(
uri
)
# Redirect is not only allowed to current host, but also to other Geo
# nodes. relative_url_root *must* be ignored here as we don't know what
# is root and what is path
super
||
begin
truncated
=
uri
.
dup
.
tap
{
|
uri
|
uri
.
path
=
'/'
}
::
GeoNode
.
with_url_prefix
(
truncated
).
exists?
end
end
end
end
ee/spec/controllers/concerns/internal_redirect_spec.rb
0 → 100644
View file @
3148355c
require
'spec_helper'
describe
InternalRedirect
do
let
(
:controller_class
)
do
Class
.
new
do
include
InternalRedirect
def
request
@request
||=
Struct
.
new
(
:host
,
:port
).
new
(
'test.host'
,
80
)
end
end
end
subject
(
:controller
)
{
controller_class
.
new
}
describe
'#host_allowed?'
do
it
'allows redirecting to existing geo nodes'
do
create
(
:geo_node
,
url:
'http://narnia.test.host'
)
expect
(
controller
.
host_allowed?
(
URI
(
'http://narnia.test.host/test'
))).
to
be
(
true
)
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