Class: VectorMCP::Security::AuthResult

Inherits:
Object
  • Object
show all
Defined in:
lib/vector_mcp/security/auth_result.rb

Overview

Value object representing the outcome of an authentication attempt. Replaces the unstructured Hash that previously flowed through the auth pipeline.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authenticated:, user: nil, strategy: nil, authenticated_at: nil) ⇒ AuthResult

Returns a new instance of AuthResult.



10
11
12
13
14
15
16
# File 'lib/vector_mcp/security/auth_result.rb', line 10

def initialize(authenticated:, user: nil, strategy: nil, authenticated_at: nil)
  @authenticated = authenticated
  @user = user
  @strategy = strategy
  @authenticated_at = authenticated_at || (Time.now if authenticated)
  freeze
end

Instance Attribute Details

#authenticated_atObject (readonly)

Returns the value of attribute authenticated_at.



8
9
10
# File 'lib/vector_mcp/security/auth_result.rb', line 8

def authenticated_at
  @authenticated_at
end

#strategyObject (readonly)

Returns the value of attribute strategy.



8
9
10
# File 'lib/vector_mcp/security/auth_result.rb', line 8

def strategy
  @strategy
end

#userObject (readonly)

Returns the value of attribute user.



8
9
10
# File 'lib/vector_mcp/security/auth_result.rb', line 8

def user
  @user
end

Class Method Details

.failureObject



24
25
26
# File 'lib/vector_mcp/security/auth_result.rb', line 24

def self.failure
  new(authenticated: false)
end

.passthroughObject



28
29
30
# File 'lib/vector_mcp/security/auth_result.rb', line 28

def self.passthrough
  new(authenticated: true)
end

.success(user:, strategy:, authenticated_at: Time.now) ⇒ Object



20
21
22
# File 'lib/vector_mcp/security/auth_result.rb', line 20

def self.success(user:, strategy:, authenticated_at: Time.now)
  new(authenticated: true, user: user, strategy: strategy, authenticated_at: authenticated_at)
end

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


18
# File 'lib/vector_mcp/security/auth_result.rb', line 18

def authenticated? = @authenticated