From 068e72307f9ce91538e45cb461b99cf92d2f5666 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 5 Sep 2019 13:16:26 -0400 Subject: [PATCH] 15529: LoginCluster uses ApiClientAuthorization.remote_host Fix misspellings. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- .../api/app/controllers/user_sessions_controller.rb | 12 +++++------- services/api/app/models/api_client_authorization.rb | 8 ++++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/services/api/app/controllers/user_sessions_controller.rb b/services/api/app/controllers/user_sessions_controller.rb index f3591345df..49af414310 100644 --- a/services/api/app/controllers/user_sessions_controller.rb +++ b/services/api/app/controllers/user_sessions_controller.rb @@ -157,18 +157,16 @@ class UserSessionsController < ApplicationController p << "auth_provider=#{CGI.escape(params[:auth_provider])}" if params[:auth_provider] if !Rails.configuration.Login.LoginCluster.empty? and Rails.configuration.Login.LoginCluster != Rails.configuration.ClusterID - cluster = Rails.configuration.RemoteClusters[Rails.configuration.Login.LoginCluster] - if not cluster + host = ApiClientAuthorization.remote_host(uuid_prefix: Rails.configuration.Login.LoginCluster) + if not host raise "LoginCluster #{Rails.configuration.Login.LoginCluster} missing from RemoteClusters" end scheme = "https" - if cluster['Scheme'] and !cluster['Scheme'].empty? + cluster = Rails.configuration.RemoteClusters[Rails.configuration.Login.LoginCluster] + if cluster and cluster['Scheme'] and !cluster['Scheme'].empty? scheme = cluster['Scheme'] end - if !cluster['Host'] or cluster['Host'].empty? - raise "LoginCluster #{Rails.configuration.Login.LoginCluster} missing 'Host' in RemoteClusters" - end - login_cluster = "#{scheme}://#{cluster['Host']}" + login_cluster = "#{scheme}://#{host}" p << "remote=#{CGI.escape(params[:remote])}" if params[:remote] p << "return_to=#{CGI.escape(params[:return_to])}" if params[:return_to] redirect_to "#{login_cluster}/login?#{p.join('&')}" diff --git a/services/api/app/models/api_client_authorization.rb b/services/api/app/models/api_client_authorization.rb index 606c3e06f8..55db16a4b5 100644 --- a/services/api/app/models/api_client_authorization.rb +++ b/services/api/app/models/api_client_authorization.rb @@ -87,8 +87,8 @@ class ApiClientAuthorization < ArvadosModel end def self.remote_host(uuid_prefix:) - (Rails.configuration.RemoteClusters[uuid_prefix].andand.Host) || - (Rails.configuration.RemoteClusters["*"].Proxy && + (Rails.configuration.RemoteClusters[uuid_prefix].andand["Host"]) || + (Rails.configuration.RemoteClusters["*"]["Proxy"] && uuid_prefix+".arvadosapi.com") end @@ -160,7 +160,7 @@ class ApiClientAuthorization < ArvadosModel return nil end - # Invarient: token_uuid_prefix != Rails.configuration.ClusterID + # Invariant: token_uuid_prefix != Rails.configuration.ClusterID # # In other words the remaing code in this method below is the # case that determines whether to accept a token that was issued @@ -199,7 +199,7 @@ class ApiClientAuthorization < ArvadosModel return nil end - # Invarient: remote_user_prefix == token_uuid_prefix + # Invariant: remote_user_prefix == token_uuid_prefix # therefore: remote_user_prefix != Rails.configuration.ClusterID # Add or update user and token in local database so we can -- 2.30.2