Sha256: 86824bc629ae34bfd6d293e020c809b2c5d3a2e691323798ea6bbb59e6516cea

Contents?: true

Size: 621 Bytes

Versions: 6

Compression:

Stored size: 621 Bytes

Contents

module Restfulness
  module Resources

    # Module to support authentication in Restfulness resources.
    module Authentication

      # Parse the request headers for HTTP Basic Authentication details and
      # run the provided block.
      # If the request does not include and basic headers or the details are invalid,
      # the block will not be called.
      def authenticate_with_http_basic
        header = request.authorization
        auth = HttpAuthentication::Basic.new(header) if header
        if auth && auth.valid?
          yield auth.username, auth.password
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
restfulness-0.3.6 lib/restfulness/resources/authentication.rb
restfulness-0.3.5 lib/restfulness/resources/authentication.rb
restfulness-0.3.4 lib/restfulness/resources/authentication.rb
restfulness-0.3.3 lib/restfulness/resources/authentication.rb
restfulness-0.3.2 lib/restfulness/resources/authentication.rb
restfulness-0.3.1 lib/restfulness/resources/authentication.rb