Class: JWTSignedRequest::Middlewares::Rack
- Inherits:
-
Object
- Object
- JWTSignedRequest::Middlewares::Rack
- Defined in:
- lib/jwt_signed_request/middlewares/rack.rb
Constant Summary collapse
- UNAUTHORIZED_STATUS_CODE =
401
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, secret_key: nil, algorithm: nil, leeway: nil, exclude_paths: nil, key_store_id: nil) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app, secret_key: nil, algorithm: nil, leeway: nil, exclude_paths: nil, key_store_id: nil) ⇒ Rack
Returns a new instance of Rack.
11 12 13 14 15 16 17 18 |
# File 'lib/jwt_signed_request/middlewares/rack.rb', line 11 def initialize(app, secret_key: nil, algorithm: nil, leeway: nil, exclude_paths: nil, key_store_id: nil) @app = app @secret_key = secret_key @algorithm = algorithm @leeway = leeway @exclude_paths = exclude_paths @key_store_id = key_store_id end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/jwt_signed_request/middlewares/rack.rb', line 20 def call(env) ::JWTSignedRequest.verify(**verification_args(env)) unless excluded_path?(env) app.call(env) rescue ::JWTSignedRequest::UnauthorizedRequestError [UNAUTHORIZED_STATUS_CODE, {'Content-Type' => 'application/json'}, []] end |