Sha256: 136fefebe7eed8edaf3b06d80903159eb7218d0df58a6972d0ab7eb33bab761b
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require "uri" require_relative "../client" module VagrantPlugins module LoginCommand class AddAuthentication def initialize(app, env) @app = app end def call(env) client = Client.new(env[:env]) token = client.token if token && Vagrant.server_url server_uri = URI.parse(Vagrant.server_url) env[:box_urls].map! do |url| u = URI.parse(url) 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. replace = u.host == "vagrantcloud.com" && server_uri.host == "atlas.hashicorp.com" end if replace u.query ||= "" u.query += "&" if u.query != "" u.query += "access_token=#{token}" end u.to_s end end @app.call(env) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-cloudstack-1.2.0 | vendor/bundle/bundler/gems/vagrant-c84e05fd063f/plugins/commands/login/middleware/add_authentication.rb |