Class: Sinatra::Authorization::ProtectedAction
- Defined in:
- lib/sinatras-hat/authentication.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #check! ⇒ Object
-
#initialize(request, credentials = {}, &block) ⇒ ProtectedAction
constructor
A new instance of ProtectedAction.
- #remote_user ⇒ Object
Constructor Details
#initialize(request, credentials = {}, &block) ⇒ ProtectedAction
Returns a new instance of ProtectedAction.
8 9 10 |
# File 'lib/sinatras-hat/authentication.rb', line 8 def initialize(request, credentials={}, &block) @credentials, @request, @block = credentials, request, block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
6 7 8 |
# File 'lib/sinatras-hat/authentication.rb', line 6 def block @block end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
6 7 8 |
# File 'lib/sinatras-hat/authentication.rb', line 6 def credentials @credentials end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/sinatras-hat/authentication.rb', line 6 def request @request end |
Instance Method Details
#check! ⇒ Object
12 13 14 15 16 |
# File 'lib/sinatras-hat/authentication.rb', line 12 def check! unless auth.provided? bad_request! unless auth.basic? unless (*auth.credentials) end |
#remote_user ⇒ Object
18 19 20 |
# File 'lib/sinatras-hat/authentication.rb', line 18 def remote_user auth.username end |