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



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

def 
  @account
end

#doorkeeper_tokenObject

Returns the value of attribute doorkeeper_token

Returns:

  • (Object)

    the current value of doorkeeper_token



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

def doorkeeper_token
  @doorkeeper_token
end

Instance Method Details

#account_nameObject



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

def 
  .full_name
end

#can_access_service?(service_key) ⇒ Boolean

Returns:

  • (Boolean)


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

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.



70
71
72
73
74
75
76
77
# File 'app/mcp/mcp_authenticator.rb', line 70

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)


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

def oauth?
  true
end

#permitted_servicesObject

Raw permitted_services from the OAuth application (empty = all)



63
64
65
# File 'app/mcp/mcp_authenticator.rb', line 63

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

#service_labelsObject

Human-readable labels for the permitted services



84
85
86
# File 'app/mcp/mcp_authenticator.rb', line 84

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