Class: McpToolkit::Auth::AuthorityServerClient
- Inherits:
-
Object
- Object
- McpToolkit::Auth::AuthorityServerClient
- Defined in:
- lib/mcp_toolkit/auth/authority_server_client.rb
Overview
SATELLITE side. The HTTP client that talks to the central authority's introspection endpoint. Owns the Faraday connection (timeouts, JSON parsing, adapter) and the POST itself, so Auth::Introspection is left with the caching and result-parsing concerns only.
POST {config.introspect_url}
Authorization: Bearer <token>
Accept: application/json
Returns the raw response body on a 200, or nil otherwise (a non-200 status or a transport-level Faraday error). Auth::Introspection turns that into an Introspection::Result.
Instance Method Summary collapse
-
#initialize(config) ⇒ AuthorityServerClient
constructor
A new instance of AuthorityServerClient.
-
#introspect(token) ⇒ Object
POSTs the token to the authority's introspection endpoint.
Constructor Details
#initialize(config) ⇒ AuthorityServerClient
Returns a new instance of AuthorityServerClient.
18 19 20 |
# File 'lib/mcp_toolkit/auth/authority_server_client.rb', line 18 def initialize(config) @config = config end |
Instance Method Details
#introspect(token) ⇒ Object
POSTs the token to the authority's introspection endpoint. Returns the response body on a 200; nil on any non-200 status or transport failure.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mcp_toolkit/auth/authority_server_client.rb', line 24 def introspect(token) response = connection.post(config.introspect_url) do |request| request.headers["Authorization"] = "Bearer #{token}" request.headers["Accept"] = "application/json" end return nil unless response.status == 200 response.body rescue Faraday::Error nil end |