X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/fb3c02b38a24cda422de95f2f8b49002b841cc72..de11b137d4469e9d54e078ac0dd5664bdb90e486:/services/api/app/models/api_client.rb?ds=inline diff --git a/services/api/app/models/api_client.rb b/services/api/app/models/api_client.rb index b3e1b2e3d3..8ed693f820 100644 --- a/services/api/app/models/api_client.rb +++ b/services/api/app/models/api_client.rb @@ -1,11 +1,37 @@ -class ApiClient < ActiveRecord::Base - include AssignUuid +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + +class ApiClient < ArvadosModel + include HasUuid include KindAndEtag include CommonApiTemplate has_many :api_client_authorizations - api_accessible :superuser, :extend => :common do |t| + api_accessible :user, extend: :common do |t| t.add :name t.add :url_prefix + t.add :is_trusted + end + + def is_trusted + norm(self.url_prefix) == norm(Rails.configuration.Services.Workbench1.ExternalURL) || + norm(self.url_prefix) == norm(Rails.configuration.Services.Workbench2.ExternalURL) || + super + end + + protected + + def norm url + # normalize URL for comparison + url = URI(url) + if url.scheme == "https" + url.port == "443" + end + if url.scheme == "http" + url.port == "80" + end + url.path = "/" + url end end