[arvados] created: 2.1.0-2691-g8be187777

git repository hosting git at public.arvados.org
Thu Jul 7 15:52:37 UTC 2022


        at  8be18777737dd656f9b41d19383d7f47f736901f (commit)


commit 8be18777737dd656f9b41d19383d7f47f736901f
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
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index c5f6d567b..4dae7278f 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -62,10 +62,10 @@ with
      permission (permission origin is self).
   */
   perm_from_start(perm_origin_uuid, target_uuid, val, traverse_owned) as (
-    
+
 WITH RECURSIVE
         traverse_graph(origin_uuid, target_uuid, val, traverse_owned, starting_set) as (
-            
+
              values (perm_origin_uuid, starting_uuid, starting_perm,
                     should_traverse_owned(starting_uuid, starting_perm),
                     (perm_origin_uuid = starting_uuid or starting_uuid not like '_____-tpzed-_______________'))
@@ -107,10 +107,10 @@ case (edges.edge_id = perm_edge_id)
        can_manage permission granted by ownership.
   */
   additional_perms(perm_origin_uuid, target_uuid, val, traverse_owned) as (
-    
+
 WITH RECURSIVE
         traverse_graph(origin_uuid, target_uuid, val, traverse_owned, starting_set) as (
-            
+
     select edges.tail_uuid as origin_uuid, edges.head_uuid as target_uuid, edges.val,
            should_traverse_owned(edges.head_uuid, edges.val),
            edges.head_uuid like '_____-j7d0g-_______________'
@@ -3182,6 +3182,7 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('20220301155729'),
 ('20220303204419'),
 ('20220401153101'),
-('20220505112900');
+('20220505112900'),
+('20220707134100');
 
 

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