Class: Rack::OAuth2::Server::Resource
- Inherits:
-
Abstract::Handler
- Object
- Abstract::Handler
- Rack::OAuth2::Server::Resource
- Defined in:
- lib/rack/oauth2/server/resource.rb,
lib/rack/oauth2/server/resource/error.rb,
lib/rack/oauth2/server/resource/bearer.rb,
lib/rack/oauth2/server/resource/bearer/error.rb
Direct Known Subclasses
Defined Under Namespace
Modules: ErrorMethods Classes: BadRequest, Bearer, Forbidden, Request, Unauthorized
Constant Summary collapse
- ACCESS_TOKEN =
'rack.oauth2.access_token'
- DEFAULT_REALM =
'Protected by OAuth 2.0'
Instance Attribute Summary collapse
-
#realm ⇒ Object
Returns the value of attribute realm.
-
#request ⇒ Object
Returns the value of attribute request.
Attributes inherited from Abstract::Handler
Instance Method Summary collapse
- #_call(env) ⇒ Object
-
#initialize(app, realm = nil, &authenticator) ⇒ Resource
constructor
A new instance of Resource.
Methods inherited from Abstract::Handler
Constructor Details
#initialize(app, realm = nil, &authenticator) ⇒ Resource
Returns a new instance of Resource.
9 10 11 12 13 |
# File 'lib/rack/oauth2/server/resource.rb', line 9 def initialize(app, realm = nil, &authenticator) @app = app @realm = realm super(&authenticator) end |
Instance Attribute Details
#realm ⇒ Object
Returns the value of attribute realm.
7 8 9 |
# File 'lib/rack/oauth2/server/resource.rb', line 7 def realm @realm end |
#request ⇒ Object
Returns the value of attribute request.
7 8 9 |
# File 'lib/rack/oauth2/server/resource.rb', line 7 def request @request end |
Instance Method Details
#_call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rack/oauth2/server/resource.rb', line 15 def _call(env) if request.oauth2? access_token = authenticate! request.setup! env[ACCESS_TOKEN] = access_token end @app.call(env) rescue Rack::OAuth2::Server::Abstract::Error => e e.realm ||= realm e.finish end |