Bug #19742
closedAPI call for fact_values is slow when user is non-admin , Foreman 1.15.0
Description
Hi Gents,
Seems the same user with admin rights can have a respond from API call within 0.1s and with limited access about 10.5s,
Logs from Foreman below:
limited user
2017-06-01 15:39:42 5cb09216 [app] [I] Started GET "/api/hosts/345/facts?per_page=999" for myhost.domain.com at 2017-06-01 15:39:42 +0200
2017-06-01 15:39:42 5cb09216 [app] [I] Processing by Api::V2::FactValuesController#index as JSON
2017-06-01 15:39:42 5cb09216 [app] [I] Parameters: {"per_page"=>"999", "apiv"=>"v2", "host_id"=>"345", "fact_value"=>{}}
2017-06-01 15:39:42 5cb09216 [app] [I] Authorized user karen(karen)
2017-06-01 15:39:53 5cb09216 [app] [I] Rendered api/v2/fact_values/index.json.rabl within api/v2/layouts/index_layout (1.6ms)
2017-06-01 15:39:53 5cb09216 [app] [I] Completed 200 OK in 10555ms (Views: 54.3ms | ActiveRecord: 190.0ms)
as admin
2017-06-01 15:40:46 3588293e [app] [I] Started GET "/api/hosts/345/facts?per_page=999" for myhost.domain.com at 2017-06-01 15:40:46 +0200
2017-06-01 15:40:46 3588293e [app] [I] Processing by Api::V2::FactValuesController#index as JSON
2017-06-01 15:40:46 3588293e [app] [I] Parameters: {"per_page"=>"999", "apiv"=>"v2", "host_id"=>"345", "fact_value"=>{}}
2017-06-01 15:40:46 3588293e [app] [I] Authorized user karen(karen)
2017-06-01 15:40:46 3588293e [app] [I] Rendered api/v2/fact_values/index.json.rabl within api/v2/layouts/index_layout (1.6ms)
2017-06-01 15:40:46 3588293e [app] [I] Completed 200 OK in 776ms (Views: 11.5ms | ActiveRecord: 18.3ms)
as user without Organization or Location assigned
2017-06-01 17:41:11 bcf71b47 [app] [I] Started GET "/api/hosts/645/facts?per_page=999" for myhost.domain.com at 2017-06-01 17:41:11 +0200
2017-06-01 17:41:11 bcf71b47 [app] [I] Processing by Api::V2::FactValuesController#index as JSON
2017-06-01 17:41:11 bcf71b47 [app] [I] Parameters: {"per_page"=>"999", "apiv"=>"v2", "host_id"=>"645", "fact_value"=>{}}
2017-06-01 17:41:11 bcf71b47 [app] [I] Authorized user karen(karen)
2017-06-01 17:41:15 bcf71b47 [app] [I] Rendered api/v2/fact_values/index.json.rabl within api/v2/layouts/index_layout (1.3ms)
2017-06-01 17:41:15 bcf71b47 [app] [I] Completed 200 OK in 3569ms (Views: 19.0ms | ActiveRecord: 68.9ms)