Sha256: 31ab189f0271e17cd947504bbf42e7152e5b2b5ec51bd3a271780bb54fd6478f

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

module Desk
  # @private
  module Authentication
    module Methods
      OAUTH = "oauth"
      BASIC = "basic"
      ALL = [
        OAUTH,
        BASIC,
      ]
    end

    private

    # Authentication hash
    #
    # @return [Hash]
    def authentication
      if auth_method == Methods::BASIC
        basic_authentication
      else
        oauth_authentication
      end
    end

    # Authentication hash for OAUTH connections
    #
    # @return [Hash]
    def oauth_authentication
      {
        :consumer_key => consumer_key,
        :consumer_secret => consumer_secret,
        :token => oauth_token,
        :token_secret => oauth_token_secret
      }
    end

    # Authentication hash for Basic auth connections
    #
    # @return [Hash]
    def basic_authentication
      {
        :username => basic_auth_username,
        :password => basic_auth_password
      }
    end

    # Check whether user is authenticated
    #
    # @return [Boolean]
    def authenticated?
      authentication.values.all?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
desk-1.2.0 lib/desk/authentication.rb
desk-1.1.1 lib/desk/authentication.rb
desk-1.1.0 lib/desk/authentication.rb
desk-1.0.10 lib/desk/authentication.rb
desk-1.0.9 lib/desk/authentication.rb