Class: SettingsService::AuthMiddleware
- Inherits:
-
Object
- Object
- SettingsService::AuthMiddleware
- Defined in:
- app/services/settings_service/auth_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, arg2) ⇒ AuthMiddleware
constructor
A new instance of AuthMiddleware.
Constructor Details
#initialize(app, arg2) ⇒ AuthMiddleware
Returns a new instance of AuthMiddleware.
3 4 5 6 |
# File 'app/services/settings_service/auth_middleware.rb', line 3 def initialize app, arg2 @arg2 = arg2 @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/services/settings_service/auth_middleware.rb', line 8 def call env key = env['HTTP_AUTHORIZATION'] key = key.delete('Bearer ') if key if AuthToken.authenticate(key) @app.call(env) else [401, {"Content-Type" => "application/json"}, ['{ "message" : "Unauthorized" }']] end end |