Merge pull request #9145 from hashicorp/login-middleware-auth-hosts
Add app.vagrantup.com to allowed auth hosts
This commit is contained in:
commit
f1863a8243
|
@ -6,8 +6,11 @@ require_relative "../client"
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module LoginCommand
|
module LoginCommand
|
||||||
class AddAuthentication
|
class AddAuthentication
|
||||||
VCLOUD = "vagrantcloud.com".freeze
|
ALLOWED_AUTHENTICATION_HOSTS = %w[
|
||||||
ATLAS = "atlas.hashicorp.com".freeze
|
app.vagrantup.com
|
||||||
|
atlas.hashicorp.com
|
||||||
|
vagrantcloud.com
|
||||||
|
].freeze
|
||||||
|
|
||||||
def initialize(app, env)
|
def initialize(app, env)
|
||||||
@app = app
|
@app = app
|
||||||
|
@ -25,12 +28,8 @@ module VagrantPlugins
|
||||||
replace = u.host == server_uri.host
|
replace = u.host == server_uri.host
|
||||||
|
|
||||||
if !replace
|
if !replace
|
||||||
# We need this in here for the transition we made from
|
if ALLOWED_AUTHENTICATION_HOSTS.include?(u.host) &&
|
||||||
# Vagrant Cloud to Atlas. This preserves access tokens
|
ALLOWED_AUTHENTICATION_HOSTS.include?(server_uri.host)
|
||||||
# appending to both without leaking access tokens to
|
|
||||||
# unsavory URLs.
|
|
||||||
if (u.host == VCLOUD && server_uri.host == ATLAS) ||
|
|
||||||
(u.host == ATLAS && server_uri.host == VCLOUD)
|
|
||||||
replace = true
|
replace = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,13 +71,15 @@ describe VagrantPlugins::LoginCommand::AddAuthentication do
|
||||||
|
|
||||||
original = [
|
original = [
|
||||||
"http://google.com/box.box",
|
"http://google.com/box.box",
|
||||||
|
"http://app.vagrantup.com/foo.box",
|
||||||
"http://vagrantcloud.com/foo.box",
|
"http://vagrantcloud.com/foo.box",
|
||||||
"http://vagrantcloud.com/bar.box?arg=true",
|
"http://vagrantcloud.com/bar.box?arg=true",
|
||||||
]
|
]
|
||||||
|
|
||||||
expected = original.dup
|
expected = original.dup
|
||||||
expected[1] = "#{original[1]}?access_token=#{token}"
|
expected[1] = "#{original[1]}?access_token=#{token}"
|
||||||
expected[2] = "#{original[2]}&access_token=#{token}"
|
expected[2] = "#{original[2]}?access_token=#{token}"
|
||||||
|
expected[3] = "#{original[3]}&access_token=#{token}"
|
||||||
|
|
||||||
env[:box_urls] = original.dup
|
env[:box_urls] = original.dup
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
|
|
Loading…
Reference in New Issue