Module: Postview::Authentication
- Included in:
- Postview::Application::Blog
- Defined in:
- lib/postview/authentication.rb
Overview
Copyright © 2009 Hallison Batista
Instance Method Summary collapse
-
#authenticate! ⇒ Object
Run HTTP Basic authentication.
- #authenticated? ⇒ Boolean
-
#authentication ⇒ Object
Returns a HTTP Basic authentication.
- #password ⇒ Object
- #username ⇒ Object
Instance Method Details
#authenticate! ⇒ Object
Run HTTP Basic authentication.
20 21 22 23 24 |
# File 'lib/postview/authentication.rb', line 20 def authenticate! headers "WWW-Authenticate" => %(Basic realm="#{@site.title}") and @error_message = "Not authorized\n" and throw(:halt, [401, erb(:error)]) and return unless authenticated? end |
#authenticated? ⇒ Boolean
26 27 28 29 30 31 |
# File 'lib/postview/authentication.rb', line 26 def authenticated? authentication.provided? && authentication.basic? && authentication.credentials && @site.authenticate?(username, password) end |
#authentication ⇒ Object
Returns a HTTP Basic authentication.
7 8 9 |
# File 'lib/postview/authentication.rb', line 7 def authentication @authentication ||= Rack::Auth::Basic::Request.new(request.env) end |
#password ⇒ Object
15 16 17 |
# File 'lib/postview/authentication.rb', line 15 def password authentication.credentials.last end |
#username ⇒ Object
11 12 13 |
# File 'lib/postview/authentication.rb', line 11 def username env["REMOTE_USER"] || authentication.credentials.first end |