Sha256: bd4fe2938a3a0c2a259d12357ef706f73f70362d2354bb85f090c2a2ece1796d

Contents?: true

Size: 877 Bytes

Versions: 13

Compression:

Stored size: 877 Bytes

Contents

# frozen_string_literal: true

module Frodo
  module Concerns
    module Authentication
      # Public: Force an authentication
      def authenticate!
        unless authentication_middleware
          raise AuthenticationError, 'No authentication middleware present'
        end

        middleware = authentication_middleware.new nil, self, options
        middleware.authenticate!
      end

      # Internal: Determines what middleware will be used based on the options provided
      def authentication_middleware
        if oauth_refresh?
          Frodo::Middleware::Authentication::Token
        end
      end

      # Internal: Returns true if oauth token refresh flow should be used for
      # authentication.
      def oauth_refresh?
        options[:refresh_token] &&
          options[:client_id] &&
          options[:client_secret]
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
frodo-0.12.2 lib/frodo/concerns/authentication.rb
frodo-0.12.1 lib/frodo/concerns/authentication.rb
frodo-0.12.0 lib/frodo/concerns/authentication.rb
frodo-0.11.0 lib/frodo/concerns/authentication.rb
frodo-0.10.8 lib/frodo/concerns/authentication.rb
frodo-0.10.7 lib/frodo/concerns/authentication.rb
frodo-0.10.6 lib/frodo/concerns/authentication.rb
frodo-0.10.5 lib/frodo/concerns/authentication.rb
frodo-0.10.4 lib/frodo/concerns/authentication.rb
frodo-0.10.3 lib/frodo/concerns/authentication.rb
frodo-0.10.2 lib/frodo/concerns/authentication.rb
frodo-0.10.1 lib/frodo/concerns/authentication.rb
frodo-0.10.0 lib/frodo/concerns/authentication.rb