[arvados] created: 2.1.0-2691-g19302ed06
git repository hosting
git at public.arvados.org
Thu Jul 7 14:28:17 UTC 2022
at 19302ed06c3478f1ef6e4e8c4db9e6cf89c039b0 (commit)
commit 19302ed06c3478f1ef6e4e8c4db9e6cf89c039b0
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..8f8305d02
--- /dev/null
+++ b/services/api/db/migrate/20220707134100_set_default_usernames.rb
@@ -0,0 +1,23 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class SetDefaultUsernames < ActiveRecord::Migration[5.2]
+ uuid_patterns = {
+ 'root' => '%-tpzed-000000000000000',
+ 'anonymous' => '%-tpzed-anonymouspublic',
+ }
+ def up
+ uuid_patterns.each_pair do |username, pattern|
+ User.where(uuid: username).where("uuid not like #{pattern}").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 like #{pattern}").andand.update!(username: username)
+ 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