Class: VectorMCP::Security::Strategies::Custom
- Inherits:
-
Object
- Object
- VectorMCP::Security::Strategies::Custom
- Defined in:
- lib/vector_mcp/security/strategies/custom.rb
Overview
Custom authentication strategy Allows developers to implement their own authentication logic
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
Instance Method Summary collapse
-
#authenticate(request) ⇒ Object, false
Authenticate a request using the custom handler.
-
#configured? ⇒ Boolean
Check if handler is configured.
-
#initialize(&handler) ⇒ Custom
constructor
Initialize with a custom authentication handler.
Constructor Details
#initialize(&handler) ⇒ Custom
Initialize with a custom authentication handler
13 14 15 16 17 |
# File 'lib/vector_mcp/security/strategies/custom.rb', line 13 def initialize(&handler) raise ArgumentError, "Custom authentication strategy requires a block" unless handler @handler = handler end |
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
9 10 11 |
# File 'lib/vector_mcp/security/strategies/custom.rb', line 9 def handler @handler end |
Instance Method Details
#authenticate(request) ⇒ Object, false
Authenticate a request using the custom handler
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vector_mcp/security/strategies/custom.rb', line 22 def authenticate(request) result = @handler.call(request) # Ensure result includes strategy info if it's successful if result && result != false format_successful_result(result) else false end rescue NoMemoryError, StandardError # Log error but return false for security false end |
#configured? ⇒ Boolean
Check if handler is configured
38 39 40 |
# File 'lib/vector_mcp/security/strategies/custom.rb', line 38 def configured? !@handler.nil? end |