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>
Created from redmine issue http://projects.theforeman.org/issues/19159
Upstream bug assigned to tstrachota
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/19159 has been resolved.
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
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