X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/90d84d8578b760b493ac76b22c42bc284868bc0c..a185309d194bb3073a5efb67d7a56a10b4a980a5:/services/api/app/models/api_client_authorization.rb diff --git a/services/api/app/models/api_client_authorization.rb b/services/api/app/models/api_client_authorization.rb index 55db16a4b5..1f244cf089 100644 --- a/services/api/app/models/api_client_authorization.rb +++ b/services/api/app/models/api_client_authorization.rb @@ -92,9 +92,11 @@ class ApiClientAuthorization < ArvadosModel uuid_prefix+".arvadosapi.com") end - def self.make_http_client + def self.make_http_client(uuid_prefix:) clnt = HTTPClient.new - if Rails.configuration.TLS.Insecure + + if uuid_prefix && (Rails.configuration.RemoteClusters[uuid_prefix].andand.Insecure || + Rails.configuration.RemoteClusters['*'].andand.Insecure) clnt.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE else # Use system CA certificates @@ -167,7 +169,7 @@ class ApiClientAuthorization < ArvadosModel # by a remote cluster when the token absent or expired in our # database. To begin, we need to ask the cluster that issued # the token to [re]validate it. - clnt = ApiClientAuthorization.make_http_client + clnt = ApiClientAuthorization.make_http_client(uuid_prefix: token_uuid_prefix) host = remote_host(uuid_prefix: token_uuid_prefix) if !host @@ -221,18 +223,13 @@ class ApiClientAuthorization < ArvadosModel if remote_user_prefix == Rails.configuration.Login.LoginCluster # Remote cluster controls our user database, copy both # 'is_active' and 'is_admin' - user.is_active = remote_user['is_active'] + user.is_active = true if remote_user['is_active'] user.is_admin = remote_user['is_admin'] else if Rails.configuration.Users.NewUsersAreActive || Rails.configuration.RemoteClusters[remote_user_prefix].andand["ActivateUsers"] - # Default policy is to activate users, so match activate - # with the remote record. - user.is_active = remote_user['is_active'] - elsif !remote_user['is_active'] - # Deactivate user if the remote is inactive, otherwise don't - # change 'is_active'. - user.is_active = false + # Default policy is to activate users + user.is_active = true if remote_user['is_active'] end end @@ -241,6 +238,10 @@ class ApiClientAuthorization < ArvadosModel end act_as_system_user do + if user.is_active && !remote_user['is_active'] + user.unsetup + end + user.save! # We will accept this token (and avoid reloading the user