Class: Apiture::Middleware::Auth::OAuth2
- Inherits:
-
Object
- Object
- Apiture::Middleware::Auth::OAuth2
- Defined in:
- lib/apiture/middleware/auth/oauth2.rb
Constant Summary collapse
- AUTHORIZATION_HEADER =
'Authorization'.freeze
- AUTHORIZATION_HEADER_FORMAT =
'Bearer %s'.freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options) ⇒ OAuth2
constructor
A new instance of OAuth2.
Constructor Details
#initialize(app, options) ⇒ OAuth2
Returns a new instance of OAuth2.
9 10 11 12 13 14 |
# File 'lib/apiture/middleware/auth/oauth2.rb', line 9 def initialize(app, ) @app = app @id = [:id] @in = [:in] @name = [:name] end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/apiture/middleware/auth/oauth2.rb', line 16 def call(env) context = env[:context] = context.[@id] token = [:token] if @in == :query env[:params][@name] = token else env[:request_headers][AUTHORIZATION_HEADER] = AUTHORIZATION_HEADER_FORMAT % token end @app.call(env) end |