Class: OAuth2::Provider::Rack::Middleware
- Inherits:
-
Object
- Object
- OAuth2::Provider::Rack::Middleware
- Defined in:
- lib/oauth2/provider/rack/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
- #thrown_response(env) ⇒ Object
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
3 4 5 |
# File 'lib/oauth2/provider/rack/middleware.rb', line 3 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/oauth2/provider/rack/middleware.rb', line 7 def call(env) request = env['oauth2'] = ResourceRequest.new(env) response = catch :oauth2 do if request.path == "/oauth/access_token" AccessTokenHandler.new(@app, env).process else @app.call(env) end end thrown_response(env) || response end |
#thrown_response(env) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/oauth2/provider/rack/middleware.rb', line 21 def thrown_response(env) if env['oauth2.response'] env['warden'] && env['warden'].custom_failure! env['oauth2.response'] end end |