Module: Restfulness::Resources::Authentication

Included in:
Restfulness::Resource
Defined in:
lib/restfulness/resources/authentication.rb

Overview

Module to support authentication in Restfulness resources.

Instance Method Summary collapse

Instance Method Details

#authenticate_with_http_basicObject

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.



11
12
13
14
15
16
17
# File 'lib/restfulness/resources/authentication.rb', line 11

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