Class: Otto::MCP::Auth::TokenMiddleware
- Inherits:
-
Object
- Object
- Otto::MCP::Auth::TokenMiddleware
- Defined in:
- lib/otto/mcp/auth/token.rb
Overview
Middleware for token authentication in MCP protocol
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, security_config = nil) ⇒ TokenMiddleware
constructor
A new instance of TokenMiddleware.
Constructor Details
#initialize(app, security_config = nil) ⇒ TokenMiddleware
Returns a new instance of TokenMiddleware.
37 38 39 40 |
# File 'lib/otto/mcp/auth/token.rb', line 37 def initialize(app, security_config = nil) @app = app @security_config = security_config end |
Instance Method Details
#call(env) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/otto/mcp/auth/token.rb', line 42 def call(env) # Only apply to MCP endpoints return @app.call(env) unless mcp_endpoint?(env) # Get auth instance from security config auth = @security_config&.mcp_auth return if auth && !auth.authenticate(env) @app.call(env) end |