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 1452774 - Session authentication doesn't work with Restclient < 1.8
Summary: Session authentication doesn't work with Restclient < 1.8
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: Unspecified
Assignee: Tomas Strachota
QA Contact: Martin Bacovsky
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-19 15:21 UTC by Ivan Necas
Modified: 2019-09-26 14:53 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:49:54 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 19159 0 High Closed Session authentication doesn't work with Restclient < 1.8 2020-01-27 23:25:25 UTC

Description Ivan Necas 2017-05-19 15:21:35 UTC
Session authentication doesn't work with restclient 1.8 that we use on production installs.
The authenticator expects http request to have uri set but this change was introduced post 1.8.

<pre>
[DEBUG 2017-04-04 07:17:49 API] Using authenticator: HammerCLIForeman::Api::SessionAuthenticatorWrapper
[ERROR 2017-04-04 07:17:49 API] undefined method `hostname' for nil:NilClass
[DEBUG 2017-04-04 07:17:49 API] #<NoMethodError: undefined method `hostname' for nil:NilClass>
[ERROR 2017-04-04 07:17:49 Exception] Error: undefined method `hostname' for nil:NilClass
Error: undefined method `hostname' for nil:NilClass
[ERROR 2017-04-04 07:17:49 Exception]
 
NoMethodError (undefined method `hostname' for nil:NilClass):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.0/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb:40:in `authenticate'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.1.0/lib/apipie_bindings/rest_client_extensions.rb:14:in `block in <module:RestClientExtensions>'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:407:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:407:in `block in transmit'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:406:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:406:in `transmit'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:176:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.8.0/lib/restclient/resource.rb:51:in `get'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.1.0/lib/apipie_bindings/api.rb:313:in `call_client'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.1.0/lib/apipie_bindings/api.rb:229:in `http_call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.1.0/lib/apipie_bindings/api.rb:179:in `call_action'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.1.0/lib/apipie_bindings/api.rb:174:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/apipie-bindings-0.1.0/lib/apipie_bindings/resource.rb:21:in `call'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.0/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.0/lib/hammer_cli_foreman/commands.rb:158:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.0/lib/hammer_cli_foreman/commands.rb:248:in `send_request'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.0/lib/hammer_cli_foreman/commands.rb:283:in `retrieve_all'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.10.0/lib/hammer_cli_foreman/commands.rb:267:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.0/lib/hammer_cli/abstract.rb:27:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.0/lib/hammer_cli/abstract.rb:27:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.0/lib/hammer_cli/abstract.rb:27:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.10.0/bin/hammer:146:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'
</pre>

Comment 1 Ivan Necas 2017-05-19 15:21:43 UTC
Created from redmine issue http://projects.theforeman.org/issues/19159

Comment 2 Ivan Necas 2017-05-19 15:21:53 UTC
Upstream bug assigned to tstrachota

Comment 4 Satellite Program 2017-05-19 16:04:49 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/19159 has been resolved.

Comment 6 Martin Bacovsky 2017-08-02 11:32:11 UTC
Verified.
Version Tested: Satellite-6.3 Snap 8

It is possible to use session auth in Hammer with RestClient (1.8.0) we ship with Satellite. 

# rpm -qa|grep rest-cli
rubygem-rest-client-1.6.7-7.el7sat.noarch
tfm-rubygem-rest-client-1.8.0-4.el7sat.noarch

Session auth is off by default and needs to turned on manually:

# grep sessions /etc/hammer/cli.modules.d/foreman.yml 
  :use_sessions: true

# hammer -d organization list
[ INFO 2017-08-02 07:24:02 Init] Initialization of Hammer CLI (0.10.2) has started...
 ....
[ INFO 2017-08-02 07:24:03 API] GET /katello/api/organizations
[DEBUG 2017-08-02 07:24:03 API] Params: {}
[DEBUG 2017-08-02 07:24:03 API] Headers: {
    :params => {}
}
[DEBUG 2017-08-02 07:24:03 API] Using authenticator: HammerCLIForeman::Api::SessionAuthenticatorWrapper
[DEBUG 2017-08-02 07:24:03 API] Response: {
       "total" => 1,
    "subtotal" => 1,
 .....
---|----------------------|-------------|----------------------|------------
ID | NAME                 | DESCRIPTION | LABEL                | DESCRIPTION
---|----------------------|-------------|----------------------|------------
1  | Default Organization |             | Default_Organization |            
---|----------------------|-------------|----------------------|------------

Note: Hammer output was reduced

# rpm -qa|grep -e ^satellite-[0-9] -e hammer_cli_foreman-
tfm-rubygem-hammer_cli_foreman-0.10.2-1.el7sat.noarch
satellite-6.3.0-16.0.beta.el7sat.noarch

Comment 7 Satellite Program 2018-02-21 16:49:54 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, 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/RHSA-2018:0336


Note You need to log in before you can comment on or make changes to this bug.