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.
48 49 50 51 |
# File 'lib/otto/mcp/auth/token.rb', line 48 def initialize(app, security_config = nil) @app = app @security_config = security_config end |
Instance Method Details
#call(env) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/otto/mcp/auth/token.rb', line 53 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 |