Class: Mathpix::MCP::HttpApp::BearerAuth
- Inherits:
-
Object
- Object
- Mathpix::MCP::HttpApp::BearerAuth
- Defined in:
- lib/mathpix/mcp/http_app.rb
Overview
Rack middleware enforcing a constant-time bearer-token check.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, token:) ⇒ BearerAuth
constructor
A new instance of BearerAuth.
Constructor Details
#initialize(app, token:) ⇒ BearerAuth
Returns a new instance of BearerAuth.
38 39 40 41 |
# File 'lib/mathpix/mcp/http_app.rb', line 38 def initialize(app, token:) @app = app @token = token end |
Instance Method Details
#call(env) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/mathpix/mcp/http_app.rb', line 43 def call(env) provided = env['HTTP_AUTHORIZATION'].to_s.sub(/\ABearer\s+/i, '') return unless Rack::Utils.secure_compare(@token, provided) @app.call(env) end |