Merge branch 'master' into 6234-user-edit-self
[arvados.git] / services / api / app / controllers / arvados / v1 / virtual_machines_controller.rb
index 10b4bd8cc60e2675e714afc321d74183556acc01..519178b0bbcf319426dbca39d181be58ef800420 100644 (file)
@@ -1,12 +1,8 @@
 class Arvados::V1::VirtualMachinesController < ApplicationController
   skip_before_filter :find_object_by_uuid, :only => :get_all_logins
   skip_before_filter :render_404_if_no_object, :only => :get_all_logins
-  skip_before_filter(:require_auth_scope_all,
-                     :only => [:logins, :get_all_logins])
   before_filter(:admin_required,
                 :only => [:logins, :get_all_logins])
-  before_filter(:require_auth_scope_for_get_all_logins,
-                :only => [:logins, :get_all_logins])
 
   def logins
     get_all_logins
@@ -28,11 +24,11 @@ class Arvados::V1::VirtualMachinesController < ApplicationController
       vm.login_permissions.each do |perm|
         user_uuid = perm.tail_uuid
         @users[user_uuid].andand.authorized_keys.andand.each do |ak|
-          username = perm.properties.andand['username']
-          if username
+          unless perm.properties['username'].blank?
             @response << {
-              username: username,
+              username: perm.properties['username'],
               hostname: vm.hostname,
+              groups: (perm.properties["groups"].to_a rescue []),
               public_key: ak.public_key,
               user_uuid: user_uuid,
               virtual_machine_uuid: vm.uuid,
@@ -42,18 +38,6 @@ class Arvados::V1::VirtualMachinesController < ApplicationController
         end
       end
     end
-    render json: { kind: "arvados#HashList", items: @response }
-  end
-
-  protected
-
-  def require_auth_scope_for_get_all_logins
-    if @object
-      # Client wants all logins for a single VM.
-      require_auth_scope(['all', arvados_v1_virtual_machine_url(@object.uuid)])
-    else
-      # ...for a non-existent VM, or all VMs.
-      require_auth_scope(['all'])
-    end
+    send_json kind: "arvados#HashList", items: @response
   end
 end