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}
32 user_uuid = perm[:user_uuid]
33 @user_aks[user_uuid] = @users[user_uuid].andand.authorized_keys.andand.
36 public_key: ak.public_key,
37 authorized_key_uuid: ak.uuid
40 if @user_aks[user_uuid].any?
41 @repo_info[repo.uuid] ||= {
44 push_url: repo.push_url,
45 fetch_url: repo.fetch_url,
48 ri = (@repo_info[repo.uuid][:user_permissions][user_uuid] ||= {})
49 ri[perm[:name]] = true
53 @repo_info.values.each do |repo_users|
54 repo_users[:user_permissions].each do |user_uuid,perms|
56 perms[:gitolite_permissions] = 'RW'
57 perms['can_read'] = true
58 elsif perms['can_read']
59 perms[:gitolite_permissions] = 'R'
64 kind: 'arvados#RepositoryPermissionSnapshot',
65 repositories: @repo_info.values,