1 class Arvados::V1::RepositoriesController < ApplicationController
2 skip_before_filter :find_object_by_uuid, :only => :get_all_permissions
3 skip_before_filter :render_404_if_no_object, :only => :get_all_permissions
4 before_filter :admin_required, :only => :get_all_permissions
5 def get_all_permissions
7 User.includes(:authorized_keys).all.each do |u|
12 @repos = Repository.includes(:permissions).all
14 gitolite_permissions = ''
16 repo.permissions.each do |perm|
17 if ArvadosModel::resource_class_for_uuid(perm.tail_uuid) == Group
18 @users.each do |user_uuid, user|
19 user.group_permissions.each do |group_uuid, perm_mask|
21 perms << {name: 'can_write', user_uuid: user_uuid}
22 elsif perm_mask[:read]
23 perms << {name: 'can_read', user_uuid: user_uuid}
28 perms << {name: perm.name, user_uuid: perm.tail_uuid}
31 # Owner of the repository, and all admins, can RW
32 ([repo.owner_uuid] + @users.keys).each do |user_uuid|
33 %w(can_read can_write).each do |name|
34 perms << {name: name, user_uuid: user_uuid}
38 user_uuid = perm[:user_uuid]
39 @user_aks[user_uuid] = @users[user_uuid].andand.authorized_keys.andand.
42 public_key: ak.public_key,
43 authorized_key_uuid: ak.uuid
46 if @user_aks[user_uuid].any?
47 @repo_info[repo.uuid] ||= {
50 push_url: repo.push_url,
51 fetch_url: repo.fetch_url,
54 ri = (@repo_info[repo.uuid][:user_permissions][user_uuid] ||= {})
55 ri[perm[:name]] = true
59 @repo_info.values.each do |repo_users|
60 repo_users[:user_permissions].each do |user_uuid,perms|
62 perms[:gitolite_permissions] = 'RW'
63 perms['can_read'] = true
64 elsif perms['can_read']
65 perms[:gitolite_permissions] = 'R'
70 kind: 'arvados#RepositoryPermissionSnapshot',
71 repositories: @repo_info.values,