Class: OAuth2::MCP::ProtectedResourceMetadata
- Inherits:
-
Object
- Object
- OAuth2::MCP::ProtectedResourceMetadata
- Defined in:
- lib/oauth2/mcp.rb
Overview
Represents OAuth protected-resource metadata for an MCP HTTP endpoint.
Instance Attribute Summary collapse
-
#authorization_servers ⇒ Object
readonly
Returns the value of attribute authorization_servers.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#scopes_supported ⇒ Object
readonly
Returns the value of attribute scopes_supported.
Instance Method Summary collapse
-
#initialize(resource:, authorization_servers:, scopes_supported: [], **metadata) ⇒ ProtectedResourceMetadata
constructor
A new instance of ProtectedResourceMetadata.
-
#to_h ⇒ Object
-
#to_json ⇒ Object
Constructor Details
#initialize(resource:, authorization_servers:, scopes_supported: [], **metadata) ⇒ ProtectedResourceMetadata
Returns a new instance of ProtectedResourceMetadata.
504 505 506 507 508 509 510 511 512 513 |
# File 'lib/oauth2/mcp.rb', line 504 def initialize(resource:, authorization_servers:, scopes_supported: [], **) @resource = normalize_required_uri(resource, "resource") @authorization_servers = Array().map do |server| normalize_required_uri(server, "authorization server") end.freeze raise ConfigurationError, "authorization_servers must not be empty" if @authorization_servers.empty? @scopes_supported = Array(scopes_supported).map(&:to_s).freeze @metadata = .transform_keys(&:to_sym).freeze end |
Instance Attribute Details
#authorization_servers ⇒ Object (readonly)
Returns the value of attribute authorization_servers.
502 503 504 |
# File 'lib/oauth2/mcp.rb', line 502 def @authorization_servers end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
502 503 504 |
# File 'lib/oauth2/mcp.rb', line 502 def @metadata end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
502 503 504 |
# File 'lib/oauth2/mcp.rb', line 502 def resource @resource end |
#scopes_supported ⇒ Object (readonly)
Returns the value of attribute scopes_supported.
502 503 504 |
# File 'lib/oauth2/mcp.rb', line 502 def scopes_supported @scopes_supported end |
Instance Method Details
#to_h ⇒ Object
515 516 517 518 519 520 521 |
# File 'lib/oauth2/mcp.rb', line 515 def to_h { resource: resource, authorization_servers: , scopes_supported: scopes_supported, }.merge().compact end |
#to_json ⇒ Object
523 524 525 |
# File 'lib/oauth2/mcp.rb', line 523 def to_json(*) JSON.generate(to_h, *) end |