X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/377467f5285670a797ec02b4ca6c5a129c289a39..ca6e3f04150dae9af6b86828a5af2a4400892487:/services/api/lib/tasks/manage_long_lived_tokens.rake diff --git a/services/api/lib/tasks/manage_long_lived_tokens.rake b/services/api/lib/tasks/manage_long_lived_tokens.rake index 8700f20f59..7a665ff7e7 100644 --- a/services/api/lib/tasks/manage_long_lived_tokens.rake +++ b/services/api/lib/tasks/manage_long_lived_tokens.rake @@ -17,6 +17,7 @@ namespace :db do end if lifetime.nil? or lifetime == 0 puts("No expiration policy set (API.MaxTokenLifetime nor Login.TokenLifetime is set), nothing to do.") + # abort the rake task next end exp_date = Time.now + lifetime @@ -25,9 +26,10 @@ namespace :db do ll_tokens(lifetime).each do |auth| if auth.user.nil? printf("*** WARNING, found ApiClientAuthorization with invalid user: auth id: %d, user id: %d\n", auth.id, auth.user_id) + # skip this token next end - if (auth.user.uuid =~ /-tpzed-000000000000000/).nil? + if (auth.user.uuid =~ /-tpzed-000000000000000/).nil? and (auth.user.uuid =~ /-tpzed-anonymouspublic/).nil? CurrentApiClientHelper.act_as_system_user do auth.update_attributes!(expires_at: exp_date) end @@ -45,6 +47,7 @@ namespace :db do end if lifetime.nil? or lifetime == 0 puts("No expiration policy set (API.MaxTokenLifetime nor Login.TokenLifetime is set), nothing to do.") + # abort the rake task next end user_ids = Set.new() @@ -52,9 +55,10 @@ namespace :db do ll_tokens(lifetime).each do |auth| if auth.user.nil? printf("*** WARNING, found ApiClientAuthorization with invalid user: auth id: %d, user id: %d\n", auth.id, auth.user_id) + # skip this token next end - if not auth.user.nil? and (auth.user.uuid =~ /-tpzed-000000000000000/).nil? + if not auth.user.nil? and (auth.user.uuid =~ /-tpzed-000000000000000/).nil? and (auth.user.uuid =~ /-tpzed-anonymouspublic/).nil? user_ids.add(auth.user_id) token_count += 1 end