1 module CurrentApiClient
7 Thread.current[:api_client]
10 def current_api_client_authorization
11 Thread.current[:api_client_authorization]
15 Thread.current[:api_url_base]
18 def current_default_owner
19 # owner_uuid for newly created objects
20 ((current_api_client_authorization &&
21 current_api_client_authorization.default_owner_uuid) ||
22 (current_user && current_user.default_owner_uuid) ||
23 (current_user && current_user.uuid) ||
27 # Where is the client connecting from?
28 def current_api_client_ip_address
29 Thread.current[:api_client_ip_address]
33 [Server::Application.config.uuid_prefix,
35 '000000000000000'].join('-')
39 [Server::Application.config.uuid_prefix,
41 '000000000000000'].join('-')
46 real_current_user = Thread.current[:user]
47 Thread.current[:user] = User.new(is_admin: true, is_active: true)
48 $system_user = User.where('uuid=?', system_user_uuid).first
50 $system_user = User.new(uuid: system_user_uuid,
59 Thread.current[:user] = real_current_user
67 ActiveRecord::Base.transaction do
68 $system_group = Group.
69 where(uuid: system_group_uuid).first_or_create do |g|
70 g.update_attributes(name: "System group",
71 description: "System group")
72 User.all.collect(&:uuid).each do |user_uuid|
73 Link.create(link_class: 'permission',
75 tail_kind: 'arvados#group',
76 tail_uuid: system_group_uuid,
77 head_kind: 'arvados#user',
87 def act_as_system_user
89 user_was = Thread.current[:user]
90 Thread.current[:user] = system_user
94 Thread.current[:user] = user_was
97 Thread.current[:user] = system_user