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 1451556

Summary: [RFE] [6.3] Describe how to use token-based authentication for the Hammer CLI
Product: Red Hat Satellite Reporter: Andrew Dahms <adahms>
Component: Docs Hammer CLI GuideAssignee: Michaela Slaninkova <mslanink>
Status: CLOSED NEXTRELEASE QA Contact: Russell Dickenson <rdickens>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.3.0CC: pondrejk
Target Milestone: UnspecifiedKeywords: FutureFeature
Target Release: Unused   
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: 2017-10-29 23:32:59 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:
Bug Depends On: 1154382    
Bug Blocks: 1486095, 1502346    

Description Andrew Dahms 2017-05-17 04:21:17 UTC
Red Hat Satellite 6.3 adds the ability to start a session to run Hammer commands so that the user only authenticates once, and subsequent commands are automatically authenticated using a token for the duration of the session. A procedure on how to start a session must be added to the Hammer CLI Guide.

Comment 2 Andrew Dahms 2017-05-23 05:38:16 UTC
Added engineering tracker to the 'depends' list.

Comment 5 Andrew Dahms 2017-08-09 02:36:59 UTC
Assigning to Misha for review.

Comment 8 Peter Ondrejka 2017-10-02 14:04:04 UTC
Hi Michaela, I checked your text again using latest snap (satellite-6.3.0-19.0.beta.el7sat.noarch) where we have a fix for 1471099 present. 

With this fix, session and stored credentials are mutually exclusive, so I'd mention probably in step one in your procedure something like "Note that if you enable sessions, username and password settings in the .yml will be ignored"

Also, I'd rather not call it tokenized authentication, this name sticked from the beginning when api tokens were considered as a possible solution, but now I'd say it is misleading. I'd call it hammer authentication sessions, so for the intro paragraph I suggest something like this:

"Another option is to use a hammer authentication session. It is a cache that stores your credentials for a specified time. You provide your Satellite credentials only once, at the beginning of the session. By using sessions you can avoid storing your credentials in the ~/.hammer/cli.modules.d/foreman.yml file. Follow these steps to use authentication sessions: "

Another problem is that changes in 6.3 make the first part of section 1.2 outdated:

"By default, hammer prompts for your Satellite credentials each time you issue a command." -- in 6.3, when you install Sat (with satellite-installer) and specify the --foreman-admin-password option, the ~/.hammer/cli.modules.d/foreman.yml file is created and populated with :username and :password options so hammer will not prompt you for creds.

If you didn't install with --foreman-admin-password, hammer will prompt for creds, but you don't need to create ~/.hammer/cli_config.yml as written in step 1, just set username/password in  ~/.hammer/cli.modules.d/foreman.yml that should already exist. Steps 2 and 3 are also no longer necessary.

Hope this helps

Comment 10 Peter Ondrejka 2017-10-04 13:35:38 UTC
Good work, just two comments:

In your config example, omit the ":host: 'https://satellite.example.com/'" no need to specify host there (I think it is set already somewhere in /etc/hammer/cli.modules.d/foreman.yml).

The concluding note. "Examples in this guide assume saved credentials.", could confuse people to think they have to use option one, I'd add "...or enabled session".

Otherwise ACK

Comment 22 Andrew Dahms 2017-10-29 23:32:59 UTC
This content shall be published with the next release of the Red Hat Satellite 6.3 Beta documentation.

Closing.