Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1243055

Summary: [RFE] Allow non admin users access to utilize hammer cli based on their roles and privileges
Product: Red Hat Satellite Reporter: Dave Sullivan <dsulliva>
Component: HammerAssignee: Katello Bug Bin <katello-bugs>
Status: CLOSED NOTABUG QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1.0CC: bkearney, dsulliva, xdmoon
Target Milestone: UnspecifiedKeywords: FutureFeature, Reopened
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-26 20:34:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dave Sullivan 2015-07-14 16:24:35 UTC
Description of problem:

Seems only admin users can utilize hammer.

Example here of creating a user with Admin privileges

http://projects.theforeman.org/issues/7284

hammer cli should allow users with certain privileges to utilize it's functionality on components that they have access to similar to UI.


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

As of 6.1

User is not created with admin attribute as noted in 7284 above

-bash-4.1$ hammer -u dhajoshi content-view info --name 'database_ccv_rhel6' --organization ACME
Forbidden - server refused to process the request

Comment 1 Bryan Kearney 2015-08-06 15:57:39 UTC
The hammer commands will not allow access to the data if the user is no authenticated. We do not have plans to have the hammer commands reconfigure based on the roles. We will expose all the hammer commands and enforce RBAC on the server.

Comment 2 Dave Sullivan 2015-08-12 14:46:42 UTC
Just putting a note here before I forget, this is not about authentication.

This is more about why in cli we have to provide --admin true for a user.

We don't think this is necessary in UI.  Also does adding --admin true in cli bypass the user RBAC/Filters.

The expectation here is that a user would just need to authenticate and RBAC rules would allow/disallow cli usage.

So why is --admin true required here and is there a corresponding requirement in the UI?

Going to reopen to ensure this is answered properly.

Comment 3 Bryan Kearney 2015-08-26 20:01:56 UTC
the --admin flag is an attribute of the users. The example which that issue is showing users create, so the command

 user create --admin true --firstname Example --lastname User --login example1 --mail root@localhost --password redhat --auth-source-id 1

is not saying, 

I __as an admin__ create user "Example User"

it is saying

I create user "Example User" __and make her an admin__

Comment 4 Dave Sullivan 2015-08-26 20:34:01 UTC
Based on my tests below I will close

I just tested this on 6.1.1 and all seems to work ok

In the UI when adding a field under Roles there is an "Administrator" that corresponds to the cli --admin true.

But it's not needed per se I didn't check it.

But you do have to provide a role, I added a "Viewer" roll.

And all works fine from the hammer cli.

[root@cragsat61 ~]# hammer -u admin user list
[Foreman] Password for admin: 
---|--------|------------------|--------------------
ID | LOGIN  | NAME             | EMAIL              
---|--------|------------------|--------------------
7  | dave   |                  | dsulliva
4  | admin  | admin admin      | crag    
3  | crag   | Craig Donnelly   | crag    
5  | kdixon | Kathryn Dixon    | kdixon  
6  | test   | test permissions |                    
---|--------|------------------|--------------------

[root@cragsat61 ~]# hammer -u admin user info --id 7
[Foreman] Password for admin: 
Id:                   7
Login:                dave
Name:                  
Email:                dsulliva
Admin:                no
Authorized by:        Internal
Last login:           2015/08/26 20:22:09
Default organization: 
Default location:     
Roles:                
    Anonymous
    Viewer
User groups:          

Organizations:        
    CragSat61
Created at:           2015/08/26 20:09:45
Updated at:           2015/08/26 20:22:09

[root@cragsat61 ~]# hammer -u dave content-view info --name "davequicktest" --organization CragSat61
[Foreman] Password for dave: 
ID:                     4
Name:                   davequicktest
Label:                  davequicktest
Composite:              
Description:            
Content Host Count:     0
Organization:           CragSat61
Yum Repositories:       
 1) ID:    6
    Name:  Red Hat Enterprise Linux 6 Server RPMs x86_64 6Server
    Label: Red_Hat_Enterprise_Linux_6_Server_RPMs_x86_64_6Server
Docker Repositories:    

Puppet Modules:         

Lifecycle Environments: 
 1) ID:   2
    Name: Library
Versions:               
 1) ID:        4
    Version:   1.0
    Published: 2015/08/24 20:36:59
 2) ID:        5
    Version:   2.0
    Published: 2015/08/24 21:04:28
Components:             

Activation Keys: