1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class ApiClient < ArvadosModel
8 include CommonApiTemplate
9 has_many :api_client_authorizations
11 api_accessible :user, extend: :common do |t|
18 (from_trusted_url && Rails.configuration.Login.IssueTrustedTokens) || super
24 norm_url_prefix = norm(self.url_prefix)
26 [Rails.configuration.Services.Workbench1.ExternalURL,
27 Rails.configuration.Services.Workbench2.ExternalURL,
28 "https://controller.api.client.invalid"].each do |url|
29 if norm_url_prefix == norm(url)
34 Rails.configuration.Login.TrustedClients.keys.each do |url|
36 if norm_url_prefix == trusted
39 if trusted.host.to_s.starts_with?("*.") &&
40 norm_url_prefix.to_s.starts_with?(trusted.scheme + "://") &&
41 norm_url_prefix.to_s.ends_with?(trusted.to_s[trusted.scheme.length + 4...])
50 # normalize URL for comparison
52 if url.scheme == "https" && url.port == ""
54 elsif url.scheme == "http" && url.port == ""