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 1828208

Summary: User must login with auth type present in the sesion after expiration
Product: Red Hat Satellite Reporter: Rahul Bajaj <rabajaj>
Component: HammerAssignee: Rahul Bajaj <rabajaj>
Status: CLOSED ERRATA QA Contact: Mirek Długosz <mzalewsk>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.8.0CC: apatel, egolov, kgaikwad, mshira, ofedoren, rabajaj, tbrisker
Target Milestone: 6.8.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-hammer_cli_foreman-2.1.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 13:32:10 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 Rahul Bajaj 2020-04-27 10:21:31 UTC
Description of problem:
Now we are able to use multiple authentication sources for logging into foreman from hammer: Basic auth, OAuth using Password Grant Flow and OAuth using the code grant flow. 

Once the user logs in using Oauth, sessions stores the authentication type and after expiration user must login using the same authentication type. But this is not happening now, user is asked to login via Basic Auth.

For example, user logs in via Oauth using Password Grant, after session expiration user is asked to login via Basic Auth.

Same happens in the case of Oauth using Code Grant flow, after session expiration user is asked to login via Basic Auth.


How reproducible:
Always


Steps to Reproduce:
1. Login via OAuth using Password Grant flow.
2. Wait for session to expire, once the session has expired
3. Run hammer os list

Actual results:
Prompt asks for user name and passowrd

Expected results:
Must ask for parameters used to login again via Oauth using Password Grant, stored in the sessions file.

Comment 3 Bryan Kearney 2020-04-27 20:58:11 UTC
Upstream bug assigned to rabajaj

Comment 4 Bryan Kearney 2020-04-27 20:58:13 UTC
Upstream bug assigned to rabajaj

Comment 5 Bryan Kearney 2020-06-01 12:03:44 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/29575 has been resolved.

Comment 6 Mirek Długosz 2020-07-01 16:21:46 UTC
Confirming that current implementation works as described in Github issue comment: https://github.com/theforeman/hammer-cli-foreman/pull/516#issuecomment-635164759

Scenario #1:
1. do not set default_auth_type in config file, or set to basic
2. log in using OAuth (`hammer auth login oauth --oidc-client-id <client> --username <user> --password <pass> --oidc-token-endpoint RHSSO_endpoing/token`)
3. wait for session to expire
4. run any hammer command

Result:
hammer asks for basic auth credentials.
User can login again using `hammer auth login oauth` command

Scenario #2:
1. set default_auth_type in config file to OAuth (password_grant was tested)
2. log in using basic auth
3. wait for session to expire
4. run any hammer command

Result:
hammer asks for OAuth credentials.
User can login again using `hammer auth login basic` command to continue using basic auth.


In other words: when you obtain session key, it is used. Once session expires, hammer asks for new login/password pair. hammer config file determines which credentials must be provided (basic or OAuth).


tested on:
Satellite 6.8.0 snap 6
katello-3.16.0-0.3.rc3.el7sat.noarch
satellite-6.8.0-0.6.beta.el7sat.noarch
foreman-2.1.0-0.22.rc3.el7sat.noarch
pulp-server-2.21.2-1.el7sat.noarch
tfm-rubygem-hammer_cli-2.1.1-1.el7sat.noarch
tfm-rubygem-hammer_cli_foreman-2.1.1-1.el7sat.noarch

Comment 7 Rahul Bajaj 2020-07-03 11:53:25 UTC
Hello Mirek,

Perfect! Thanks for summing it again from the PR :)

Comment 10 errata-xmlrpc 2020-10-27 13:32:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Satellite 6.8 Satellite Tools Release), and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHBA-2020:4367