Sha256: 9cb6335fb877cea0a8eaf702fff74fd2627c291fa3e6add224252555e72e06b4

Contents?: true

Size: 1.46 KB

Versions: 20

Compression:

Stored size: 1.46 KB

Contents

module HaveAPI::CLI
  module Authentication
    # Base class for CLI interface of authentication providers
    class Base
      class << self
        # Register this class as authentication provider with +name+.
        # The +name+ must be the same as is used in client auth provider
        # and on server side.
        # All providers have to register.
        def register(name)
          HaveAPI::CLI::Cli.register_auth_method(name, Kernel.const_get(to_s))
        end
      end

      attr_accessor :communicator

      def initialize(opts = {})
        opts ||= {}

        opts.each do |k, v|
          instance_variable_set("@#{k}", v)
        end
      end

      # Implement this method to add CLI options for auth provider.
      # +opts+ is an instance of OptionParser.
      # This method is NOT called if the auth provider has been loaded
      # from the config and wasn't specified as a command line option
      # and therefore all necessary information must be stored in the config.
      def options(opts)

      end

      # Implement this method to check if all needed information
      # for successful authentication are provided.
      # Ask the user on stdin if something is missing.
      def validate

      end

      # This method should call HaveAPI::Client::Communicator#authenticate
      # with arguments specific for this authentication provider.
      def authenticate

      end

      def save
        @communicator.auth_save
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
haveapi-client-0.12.1 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.12.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.11.1 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.11.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.10.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.9.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.8.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.7.1 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.7.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.6.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.5.4 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.5.3 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.5.2 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.5.1 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.5.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.4.2 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.4.1 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.4.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.3.0 lib/haveapi/cli/authentication/base.rb
haveapi-client-0.2.0 lib/haveapi/cli/authentication/base.rb