Sha256: 9b631355a792ab87e0204283ae66726a6ddf1ba550d47b6b49b760cafb5f1063

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 KB

Contents

module HaveAPI::Fs::Auth
  # Base class for all authentication methods.
  class Base
    def self.method_name
      @method_name
    end

    # All authentication providers must register using this method.
    # @param [Symbol] name
    def self.register(name)
      HaveAPI::Fs.register_auth(name, self)
      @method_name = name
    end
    
    # Check if this authentication provider should be used based on `opts`.
    # @param [Hash] opts mount options
    def self.use?(opts)
      false
    end

    # @param [Hash] cfg server config
    # @param [Hash] opts mount options
    def initialize(cfg, opts)
      @cfg = cfg
      @opts = opts

      setup
    end

    # Called right after {#initialize}.
    def setup

    end

    def name
      self.class.method_name
    end

    # In this method, the provider should check if it has all needed
    # information. Missing pieces can be queried from the user on stdin.
    def validate

    end

    # Authenticate the `client` object
    # @param [HaveAPI::Client::Client] client
    def authenticate(client)
      
    end

    # Check whether the authentication works by running some real API request.
    def check(client)
      client.user.current
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
haveapi-fs-0.11.0 lib/haveapi/fs/auth/base.rb
haveapi-fs-0.10.0 lib/haveapi/fs/auth/base.rb
haveapi-fs-0.9.0 lib/haveapi/fs/auth/base.rb
haveapi-fs-0.8.0 lib/haveapi/fs/auth/base.rb
haveapi-fs-0.7.1 lib/haveapi/fs/auth/base.rb
haveapi-fs-0.7.0 lib/haveapi/fs/auth/base.rb
haveapi-fs-0.1.0 lib/haveapi/fs/auth/base.rb