Sha256: b4e787485c1bee7daf6e8b8fe08669783c944c6304cdc4aba7b18048fbeff0cb

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

module HammerCLIForeman
  module Api
    class NegotiateAuth < ApipieBindings::Authenticators::Negotiate
      def initialize(foreman_url, **options)
        super("#{foreman_url}/users/extlogin", HammerCLI::SSLOptions.new.get_options(foreman_url).merge(options))
      end

      def user
        _('current Kerberos user')
      end

      def session_id
        auth_cookie&.delete_prefix('_session_id=')
      end

      def status
        if system('klist')
          _('No session, but there is an active Kerberos session, that will be used for negotiate login.')
        else
          _('There is no active Kerberos session. Have you run %s?') % 'kinit'
        end
      end

      def error(ex)
        super unless ex.is_a?(RestClient::Unauthorized)

        message = _('Invalid username or password.')
        begin
          message = JSON.parse(ex.response.body)['error']['message']
        rescue
        end
        UnauthorizedError.new(message)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hammer_cli_foreman-3.4.0 lib/hammer_cli_foreman/api/negotiate_auth.rb
hammer_cli_foreman-3.3.0 lib/hammer_cli_foreman/api/negotiate_auth.rb