Bug 1427987

Summary: [downstream clone - 4.1.1] Provide a configuration to enable that user actions should succeed regardless of 'filter' parameter
Product: Red Hat Enterprise Virtualization Manager Reporter: rhev-integ
Component: ovirt-engineAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED ERRATA QA Contact: Aleksei Slaikovskii <aslaikov>
Severity: medium Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: bgraveno, bugs, gklein, lsurette, lsvaty, mgoldboi, mperina, rbalakri, Rhev-m-bugs, srevivo, ykaul
Target Milestone: ovirt-4.1.1-1Keywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
The API supports the 'filter' parameter to indicate if results should be filtered according to the permissions of the user. Due to the way this is implemented, non admin users need to set this parameter for almost all operations because the default value is 'false'. To simplify things for non admin users, a configuration option ENGINE_API_FILTER_BY_DEFAULT has been added which allows you to change the default value to 'true', but only for non admin users. If the value is explicitly given in a request it will be honoured. If you change the value of ENGINE_API_FILTER_BY_DEFAULT to 'true', be aware that this is not backwards compatible, as clients that used non admin users and did not explicitly provide the 'filter' parameter will start to behave differently. However, this is unlikely because calls from non admin users without 'filter=true' is almost useless. If it is necessary to change the default behaviour, it can be achieved by changing this parameter in a configuration file inside the '/etc/ovirt-engine/engine.conf.d' directory. For example: # echo 'ENGINE_API_FILTER_BY_DEFAULT="true"' > \ /etc/ovirt-engine/engine.conf.d/99-filter-by-default.conf # systemctl restart ovirt-engine
Story Points: ---
Clone Of: 1420310 Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1420310    
Bug Blocks:    
Attachments:
Description Flags
Python SDK StorageAdmin disk creation none

Description rhev-integ 2017-03-01 16:17:25 UTC
+++ This bug is an upstream to downstream clone. The original bug is: +++
+++   bug 1420310 +++
======================================================================

Description of problem:
When a rest-api action is invoked by a user without providing 'filter' parameter, it may fail due to insufficient permissions for the internal queries.
This is problematic for the python sdk which supports 'filter' argument only for service listing (and not for actions).

E.g.
Creating a disk using sdk-python fails due to insufficient permissions for GetStorageDomainListByIdQuery / GetStorageDomainByIdQuery:

disk = disks_service.add(
    disk=types.Disk(
        name='mydisk',
        description='My disk',
        format=types.DiskFormat.RAW,
        provisioned_size=2 * 2**30,
        storage_domains=[
            types.StorageDomain(
                id='43b457ae-e3b6-434d-8a9f-b234b1976e5f',
            ),
        ],
    )
)

Version-Release number of selected component (if applicable):
4.1

How reproducible:
100%

Actual results:
Fails on 'Query execution failed due to insufficient permissions.'

Expected results:
Should succeed if the user has sufficient permissions to perform the action.

(Originally by Daniel Erez)

Comment 1 rhev-integ 2017-03-01 16:17:33 UTC
Juan is trying to find a definitive solution for that, so targetting now to 4.2 and we can decide to retarget when we have solution ready

(Originally by Martin Perina)

Comment 3 rhev-integ 2017-03-01 16:17:39 UTC
There are many possible solutions to this, all of them quite complicated. The long term solution should be to remove the 'filter' concept and just make all queries filter the results according to the permissions of the user, by default. But doing that is a very large task, far beyond what can be done in the API. The only reasonable solution to this that I see is to make set 'filter=true' the default for non admin users. That is what the proposed patch does. As that is a backwards compatibility breaking change, it also introduces a configuration parameter to revert to the old behavior, for the few cases where the old behavior will actually be needed.

(Originally by juan.hernandez)

Comment 4 rhev-integ 2017-03-01 16:17:45 UTC
This could also be back-ported, changing the default value of the parameter to 'false'.

(Originally by juan.hernandez)

Comment 8 Martin Perina 2017-03-17 19:57:05 UTC
It missed 4.1.1.5 build

Comment 9 Aleksei Slaikovskii 2017-04-10 10:52:36 UTC
Created attachment 1270457 [details]
Python SDK StorageAdmin disk creation

Verified on ovirt-engine-4.1.1.8-0.1.el7.noarch, python-ovirt-engine-sdk4-4.1.3-1.el7ev.x86_64

Comment 10 Juan Hernández 2017-04-13 20:36:41 UTC
Byron, I did an small edit to the doc text to remove the "this patch ..." words, as that make sense in the description of the patch, but not in the release note. I'd appreciate if you can review the text again.