Class: KeycloakApiRails::Middleware
- Inherits:
-
Object
- Object
- KeycloakApiRails::Middleware
- Defined in:
- lib/keycloak-api-rails/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
4 5 6 |
# File 'lib/keycloak-api-rails/middleware.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/keycloak-api-rails/middleware.rb', line 8 def call(env) method = env["REQUEST_METHOD"] path = env["PATH_INFO"] if service.need_middleware_authentication?(method, path, env) logger.debug("Start authentication for #{method} : #{path}") begin authenticate(env) rescue TokenError => e logger.debug("The error causing the Token to fail: #{e.original_error&. || e.}") return authentication_failed(e.) end else logger.debug("Skip authentication for #{method} : #{path}") end @app.call(env) end |