Bug 1539814

Summary: Display properly if permissions are assigned to a user or a group when accessing /ovirt-engine/api/<RESOURCE>/<ID>/permissions
Product: [oVirt] ovirt-engine Reporter: jniederm
Component: RestAPIAssignee: Ori Liel <oliel>
Status: CLOSED CURRENTRELEASE QA Contact: Radim Hrazdil <rhrazdil>
Severity: medium Docs Contact:
Priority: unspecified    
Version: futureCC: bugs, lsvaty, michal.skrivanek, mperina, oliel
Target Milestone: ovirt-4.2.2Flags: rule-engine: ovirt-4.2+
rule-engine: blocker+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-29 10:55:55 UTC Type: Bug
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:    
Bug Blocks: 1550568    

Description jniederm 2018-01-29 16:33:57 UTC
Description of problem:
It would be nice for user to be able to find out what action is he/she allowed to perform. This would allow to create more user friendly REST API based UIs. For example: "New VM" button may be disabled for users that don't have permission to create a new VM.

Version-Release number of selected component (if applicable):
current master, commit 8ebd58feca

How reproducible:
100%

Steps to Reproduce:
1. Fire api request
GET /users/{user_id}/permissions
Filter: true
Authorization: ...

using non-admin user

Actual results:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<permissions/>

Expected results:
List of permissions

Additional info:

Comment 1 Michal Skrivanek 2018-02-20 14:59:44 UTC
blocks VM Portal ability to find out if user can call an action or not

Comment 2 jniederm 2018-02-20 15:27:56 UTC
(In reply to Michal Skrivanek from comment #1)
> blocks VM Portal ability to find out if user can call an action or not

For example: It would be nice to have Create VM dialog accessible only for users that have VmCreator role assigned - https://github.com/oVirt/ovirt-web-ui/issues/286.

Comment 3 jniederm 2018-02-20 16:30:09 UTC
Allow API listing of clusters current user can create new VM in (that is: clusters that current user has VmCreate role to).

It can be realized for example using query parameter 'canCreateVm':

    GET api/clusters
    Filter: true
    
    returns all clusters current user can see (already implemented)


    GET api/clusters?canCreateVm=true
    Filter: true

    returns all clusters current user can create new VM in (RFE)

As mentioned in comment 2, it is supposed to allow UI to properly enable/disable create VM functionality and show the right set of clusters in new VM dialog.

Comment 4 Ondra Machacek 2018-02-28 11:03:48 UTC
I think that the current behavior should be good enough to implement the proposed functionality.

The user can list the permissions (also inherited) via API for specific object using following request (as an example I use cluster 123):

GET /ovirt-engine/api/clusters/123/permissions

With this request you will receive all the permissions user has, also inherited permissions and also all groups which has permissions on that cluster.
So client application need to check if the roles that are assigned to that object has specific action group, he looks for.

Client app also need to check if he is part of the group which has some permissions on that object:

GET /ovirt-engine/api/users/123/groups

With this approach it should work just OK.

The only issue we have is that when user has *only* inherited permissions on some object we don't return any permissions. That must be fixed.

Comment 5 Martin Perina 2018-03-02 10:40:16 UTC
Removing dependency on BZ1550568, which will fix most important issue in VM Portal.

We will use this RFE to fix displaying direct and inherited permissions from parent resources, which may be needed if VM Portal or other RESTAPI client will need more detailed access to each resource (we already this functionality within webadmin, but it's not exposed in RESTAPI).

Comment 6 Michal Skrivanek 2018-03-07 19:07:51 UTC
the current patch from Ondra seems to be enough for ovirt-web-ui (we can work around lack of inherited perms), but it is required in 4.2
please retarget

Comment 7 Martin Perina 2018-03-08 11:44:11 UTC
After further offline disccussion, we are changing this to a bug, the problem was on distinguishing permission for users or groups (bug) and not in not showing inherited permissions (RFE)

Comment 8 Yaniv Kaul 2018-03-15 14:02:12 UTC
Is this on track to 4.2.2? If not, please defer to 4.2.3.

Comment 9 Radim Hrazdil 2018-03-26 13:09:18 UTC
Verified in a similar manner as BZ1550165 .

Version:4.2.2.5-0.1.el7

Comment 10 Sandro Bonazzola 2018-03-29 10:55:55 UTC
This bugzilla is included in oVirt 4.2.2 release, published on March 28th 2018.

Since the problem described in this bug report should be
resolved in oVirt 4.2.2 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.

Comment 11 Red Hat Bugzilla 2023-09-14 04:16:04 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days