Module: Sinatra::AbstractAuthorization
- Included in:
- BasicAuthorization, DigestAuthorization
- Defined in:
- lib/amp/server/extension/authorization.rb
Overview
Code adapted from Ryan Tomayko and Christopher Schneid, shared under an MIT License Code significantly refactored for Amp
Instance Method Summary collapse
-
#authorized? ⇒ Boolean
(also: #logged_in?)
Convenience method to determine if a user is logged in.
- #bad_request! ⇒ Object
-
#current_user ⇒ Object
Name provided by the current user to log in.
- #unauthorized!(www_authenticate = challenge) ⇒ Object
Instance Method Details
#authorized? ⇒ Boolean Also known as: logged_in?
Convenience method to determine if a user is logged in
21 22 23 |
# File 'lib/amp/server/extension/authorization.rb', line 21 def !!request.env['REMOTE_USER'] end |
#bad_request! ⇒ Object
16 17 18 |
# File 'lib/amp/server/extension/authorization.rb', line 16 def bad_request! throw :halt, [ 400, 'Bad Request' ] end |
#current_user ⇒ Object
Name provided by the current user to log in
27 28 29 |
# File 'lib/amp/server/extension/authorization.rb', line 27 def current_user request.env['REMOTE_USER'] end |
#unauthorized!(www_authenticate = challenge) ⇒ Object
11 12 13 14 |
# File 'lib/amp/server/extension/authorization.rb', line 11 def (www_authenticate = challenge) response["WWW-Authenticate"] = challenge throw :halt, [ 401, 'Authorization Required' ] end |