:api: private
# File lib/merb-core/controller/mixins/authentication.rb, line 88 def initialize(controller, realm = "Application", &authenticator) @controller = controller @realm = realm @auth = Rack::Auth::Basic::Request.new(@controller.request.env) authenticate_or_request(&authenticator) if authenticator end
Determines whether or not the user is authenticated using the criteria in the provided authenticator block.
&authenticator |
A block that decides whether the provided username and password |
are valid.
False if basic auth is not provided, otherwise the return value of the authenticator block. |
@overridable :api: public
# File lib/merb-core/controller/mixins/authentication.rb, line 107 def authenticate(&authenticator) if @auth.provided? and @auth.basic? authenticator.call(*@auth.credentials) else false end end
The password provided in the request. |
:api: public
# File lib/merb-core/controller/mixins/authentication.rb, line 158 def password provided? ? @auth.credentials.last : nil end
Boolean |
Whether there has been any basic authentication credentials provided |
:api: public
# File lib/merb-core/controller/mixins/authentication.rb, line 142 def provided? @auth.provided? end
Request basic authentication and halt the filter chain. This is for use in a before filter.
:halt with an "HTTP Basic: Access denied." message with no layout, and sets the status to Unauthorized.
:api: public
# File lib/merb-core/controller/mixins/authentication.rb, line 121 def request request! throw :halt, @controller.render("HTTP Basic: Access denied.\n", :status => Unauthorized.status, :layout => false) end
Sets headers to request basic auth.
Returns the empty string to provide a response body. |
:api: public
# File lib/merb-core/controller/mixins/authentication.rb, line 132 def request! @controller.status = Unauthorized.status @controller.headers['WWW-Authenticate'] = 'Basic realm="%s"' % @realm "" end
Generated with the Darkfish Rdoc Generator 2.