Class: Utility::Middleware::BearerAuth
- Inherits:
-
Object
- Object
- Utility::Middleware::BearerAuth
- Defined in:
- lib/utility/middleware/bearer_auth.rb
Constant Summary collapse
- AUTHORIZATION =
'Authorization'
Instance Attribute Summary collapse
-
#bearer_auth_token ⇒ Object
readonly
Returns the value of attribute bearer_auth_token.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app = nil, options = {}) ⇒ BearerAuth
constructor
A new instance of BearerAuth.
Constructor Details
#initialize(app = nil, options = {}) ⇒ BearerAuth
Returns a new instance of BearerAuth.
16 17 18 19 |
# File 'lib/utility/middleware/bearer_auth.rb', line 16 def initialize(app = nil, = {}) @app = app @bearer_auth_token = .fetch(:bearer_auth_token) end |
Instance Attribute Details
#bearer_auth_token ⇒ Object (readonly)
Returns the value of attribute bearer_auth_token.
14 15 16 |
# File 'lib/utility/middleware/bearer_auth.rb', line 14 def bearer_auth_token @bearer_auth_token end |
Instance Method Details
#call(env) ⇒ Object
21 22 23 24 |
# File 'lib/utility/middleware/bearer_auth.rb', line 21 def call(env) env.request_headers[AUTHORIZATION] = "Bearer #{bearer_auth_token}" @app.call(env) end |