X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/cabf89d1fd8b40a2624d101a95c6587bfdd91fed..4a1735427d84743f6c2f3576263fdcae397cf9e9:/services/api/app/models/api_client.rb diff --git a/services/api/app/models/api_client.rb b/services/api/app/models/api_client.rb index 015b61dc49..791b971680 100644 --- a/services/api/app/models/api_client.rb +++ b/services/api/app/models/api_client.rb @@ -15,7 +15,7 @@ class ApiClient < ArvadosModel end def is_trusted - (from_trusted_url && Rails.configuration.Login.TokenLifetime == 0) || super + (from_trusted_url && Rails.configuration.Login.IssueTrustedTokens) || super end protected @@ -32,7 +32,13 @@ class ApiClient < ArvadosModel end Rails.configuration.Login.TrustedClients.keys.each do |url| - if norm_url_prefix == norm(url) + trusted = norm(url) + if norm_url_prefix == trusted + return true + end + if trusted.host.to_s.starts_with?("*.") && + norm_url_prefix.to_s.starts_with?(trusted.scheme + "://") && + norm_url_prefix.to_s.ends_with?(trusted.to_s[trusted.scheme.length + 4...]) return true end end @@ -43,13 +49,14 @@ class ApiClient < ArvadosModel def norm url # normalize URL for comparison url = URI(url.to_s) - if url.scheme == "https" - url.port == "443" - end - if url.scheme == "http" - url.port == "80" + if url.scheme == "https" && url.port == "" + url.port = "443" + elsif url.scheme == "http" && url.port == "" + url.port = "80" end url.path = "/" + url.query = nil + url.fragment = nil url end end