Change allowed auth hosts to list

This commit is contained in:
Justin Campbell 2017-11-07 10:32:33 -05:00
parent b3b98e77ed
commit c5266e98b8
1 changed files with 6 additions and 8 deletions

View File

@ -6,8 +6,10 @@ require_relative "../client"
module VagrantPlugins
module LoginCommand
class AddAuthentication
VCLOUD = "vagrantcloud.com".freeze
ATLAS = "atlas.hashicorp.com".freeze
ALLOWED_AUTHENTICATION_HOSTS = %w[
atlas.hashicorp.com
vagrantcloud.com
].freeze
def initialize(app, env)
@app = app
@ -25,12 +27,8 @@ module VagrantPlugins
replace = u.host == server_uri.host
if !replace
# We need this in here for the transition we made from
# Vagrant Cloud to Atlas. This preserves access tokens
# 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)
if ALLOWED_AUTHENTICATION_HOSTS.include?(u.host) &&
ALLOWED_AUTHENTICATION_HOSTS.include?(server_uri.host)
replace = true
end
end