X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d28b1cebc8b799ea1e65a50826602392b446ea29..415910149bed2eef6ae818b7c059d413934df06e:/services/api/app/controllers/arvados/v1/links_controller.rb diff --git a/services/api/app/controllers/arvados/v1/links_controller.rb b/services/api/app/controllers/arvados/v1/links_controller.rb index f76af60bb9..f54c4a9a51 100644 --- a/services/api/app/controllers/arvados/v1/links_controller.rb +++ b/services/api/app/controllers/arvados/v1/links_controller.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + class Arvados::V1::LinksController < ApplicationController def check_uuid_kind uuid, kind @@ -20,7 +24,7 @@ class Arvados::V1::LinksController < ApplicationController end def get_permissions - if current_user.can?(manage: @object) + if current_user.andand.can?(manage: @object) # find all links and return them @objects = Link.where(link_class: "permission", head_uuid: params[:uuid]) @@ -34,16 +38,26 @@ class Arvados::V1::LinksController < ApplicationController protected - # Override find_object_by_uuid: the get_permissions method may be - # called on a uuid belonging to any class. def find_object_by_uuid if action_name == 'get_permissions' + # get_permissions accepts a UUID for any kind of object. @object = ArvadosModel::resource_class_for_uuid(params[:uuid]) .readable_by(*@read_users) .where(uuid: params[:uuid]) .first else super + if @object.nil? + # Normally group permission links are not readable_by users. + # Make an exception for users with permission to manage the group. + # FIXME: Solve this more generally - see the controller tests. + link = Link.find_by_uuid(params[:uuid]) + if (not link.nil?) and + (link.link_class == "permission") and + (@read_users.any? { |u| u.can?(manage: link.head_uuid) }) + @object = link + end + end end end @@ -52,7 +66,7 @@ class Arvados::V1::LinksController < ApplicationController super # head_kind and tail_kind columns are now virtual, - # equivilent functionality is now provided by + # equivalent functionality is now provided by # 'is_a', so fix up any old-style 'where' clauses. if @where @filters ||= [] @@ -72,7 +86,7 @@ class Arvados::V1::LinksController < ApplicationController super # head_kind and tail_kind columns are now virtual, - # equivilent functionality is now provided by + # equivalent functionality is now provided by # 'is_a', so fix up any old-style 'filter' clauses. @filters = @filters.map do |k| if k[0] == 'head_kind' and k[1] == '='