Class: McpAuthenticator::OAuthAuthResult

Inherits:
Struct
  • Object
show all
Defined in:
app/mcp/mcp_authenticator.rb

Overview

Result of successful authentication via Doorkeeper OAuth token.
Service access is scoped by the OAuth application's permitted_services.
If permitted_services is empty/nil, grants access to ALL services (backward compatible).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountObject

Returns the value of attribute account

Returns:

  • (Object)

    the current value of account



49
50
51
# File 'app/mcp/mcp_authenticator.rb', line 49

def 
  @account
end

#doorkeeper_tokenObject

Returns the value of attribute doorkeeper_token

Returns:

  • (Object)

    the current value of doorkeeper_token



49
50
51
# File 'app/mcp/mcp_authenticator.rb', line 49

def doorkeeper_token
  @doorkeeper_token
end

Instance Method Details

#account_nameObject



50
51
52
# File 'app/mcp/mcp_authenticator.rb', line 50

def 
  .full_name
end

#can_access_service?(service_key) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'app/mcp/mcp_authenticator.rb', line 75

def can_access_service?(service_key)
  effective_services.include?(service_key.to_s)
end

#effective_servicesObject

Effective services list: if permitted_services is set, scope to those + content.
If empty, grant all non-sensitive services (backward compatible for existing OAuth apps).
Sensitive services (e.g., call_recordings) always require explicit permission.



66
67
68
69
70
71
72
73
# File 'app/mcp/mcp_authenticator.rb', line 66

def effective_services
  services = permitted_services
  if services.any?
    (services | ApiAuthentication::DEFAULT_SERVICES).sort
  else
    (ApiAuthentication::UPSTREAM_SERVICES.keys - ApiAuthentication::SENSITIVE_SERVICES).sort
  end
end

#oauth?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/mcp/mcp_authenticator.rb', line 54

def oauth?
  true
end

#permitted_servicesObject

Raw permitted_services from the OAuth application (empty = all)



59
60
61
# File 'app/mcp/mcp_authenticator.rb', line 59

def permitted_services
  doorkeeper_token.application&.permitted_services.presence || []
end

#service_labelsObject

Human-readable labels for the permitted services



80
81
82
# File 'app/mcp/mcp_authenticator.rb', line 80

def service_labels
  effective_services.filter_map { |key| ApiAuthentication::UPSTREAM_SERVICES.dig(key, :label) }
end