[arvados] created: 2.1.0-2691-g66a8886f1
git repository hosting
git at public.arvados.org
Thu Jul 7 15:02:38 UTC 2022
at 66a8886f1eaa4bf2616f16e73a8c1b11aff81a36 (commit)
commit 66a8886f1eaa4bf2616f16e73a8c1b11aff81a36
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Thu Jul 7 11:27:35 2022 -0300
18858: Adds rails migration to set up system users' usernames.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/services/api/db/migrate/20220707134100_set_default_usernames.rb b/services/api/db/migrate/20220707134100_set_default_usernames.rb
new file mode 100644
index 000000000..00015ada9
--- /dev/null
+++ b/services/api/db/migrate/20220707134100_set_default_usernames.rb
@@ -0,0 +1,27 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class SetDefaultUsernames < ActiveRecord::Migration[5.2]
+ include CurrentApiClient
+
+ def up
+ uuids = {
+ 'root' => system_user_uuid,
+ 'anonymous' => anonymous_user_uuid,
+ }
+ act_as_system_user do
+ uuids.each_pair do |username, uuid|
+ User.where(username: username).where.not(uuid: uuid).find_each.with_index do |user, index|
+ # This should happen at most once
+ user.username = "#{username}#{index+1}"
+ user.save!
+ end
+ User.find_by(uuid: uuid).andand.update!(username: username)
+ end
+ end
+ end
+
+ def down
+ end
+end
commit 025c0d0e3cd02231fff777daaf98d0c5dc59cb02
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Thu Jul 7 10:09:46 2022 -0300
18858: Adds default usernames to root & anonymous system users on new clusters.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/services/api/lib/current_api_client.rb b/services/api/lib/current_api_client.rb
index ee666b77a..a553e1ad9 100644
--- a/services/api/lib/current_api_client.rb
+++ b/services/api/lib/current_api_client.rb
@@ -84,6 +84,7 @@ module CurrentApiClient
first_or_create!(is_active: true,
is_admin: true,
email: 'root',
+ username: 'root',
first_name: 'root',
last_name: '')
ensure
@@ -187,6 +188,7 @@ module CurrentApiClient
first_or_create!(is_active: false,
is_admin: false,
email: 'anonymous',
+ username: 'anonymous',
first_name: 'Anonymous',
last_name: '') do |u|
u.save!
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list