Class: MCPClient::Auth::ClientInfo
- Inherits:
-
Object
- Object
- MCPClient::Auth::ClientInfo
- Defined in:
- lib/mcp_client/auth.rb
Overview
Registered OAuth client information
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_id_issued_at ⇒ Object
readonly
Returns the value of attribute client_id_issued_at.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#client_secret_expires_at ⇒ Object
readonly
Returns the value of attribute client_secret_expires_at.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Class Method Summary collapse
-
.build_metadata_from_hash(metadata_data) ⇒ ClientMetadata
Build ClientMetadata from hash data.
-
.extract_auth_method(metadata_data) ⇒ String
Extract token endpoint auth method from metadata.
-
.from_h(data) ⇒ ClientInfo
Create client info from hash.
Instance Method Summary collapse
-
#client_secret_expired? ⇒ Boolean
Check if client secret is expired.
-
#initialize(client_id:, metadata:, client_secret: nil, client_id_issued_at: nil, client_secret_expires_at: nil) ⇒ ClientInfo
constructor
A new instance of ClientInfo.
-
#to_h ⇒ Hash
Convert to hash for serialization.
Constructor Details
#initialize(client_id:, metadata:, client_secret: nil, client_id_issued_at: nil, client_secret_expires_at: nil) ⇒ ClientInfo
151 152 153 154 155 156 157 158 |
# File 'lib/mcp_client/auth.rb', line 151 def initialize(client_id:, metadata:, client_secret: nil, client_id_issued_at: nil, client_secret_expires_at: nil) @client_id = client_id @client_secret = client_secret @client_id_issued_at = client_id_issued_at @client_secret_expires_at = client_secret_expires_at = end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
144 145 146 |
# File 'lib/mcp_client/auth.rb', line 144 def client_id @client_id end |
#client_id_issued_at ⇒ Object (readonly)
Returns the value of attribute client_id_issued_at.
144 145 146 |
# File 'lib/mcp_client/auth.rb', line 144 def client_id_issued_at @client_id_issued_at end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
144 145 146 |
# File 'lib/mcp_client/auth.rb', line 144 def client_secret @client_secret end |
#client_secret_expires_at ⇒ Object (readonly)
Returns the value of attribute client_secret_expires_at.
144 145 146 |
# File 'lib/mcp_client/auth.rb', line 144 def client_secret_expires_at @client_secret_expires_at end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
144 145 146 |
# File 'lib/mcp_client/auth.rb', line 144 def end |
Class Method Details
.build_metadata_from_hash(metadata_data) ⇒ ClientMetadata
Build ClientMetadata from hash data
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/mcp_client/auth.rb', line 199 def self.() ClientMetadata.new( redirect_uris: [:redirect_uris] || ['redirect_uris'] || [], token_endpoint_auth_method: extract_auth_method(), grant_types: [:grant_types] || ['grant_types'] || %w[authorization_code refresh_token], response_types: [:response_types] || ['response_types'] || ['code'], scope: [:scope] || ['scope'], client_name: [:client_name] || ['client_name'], client_uri: [:client_uri] || ['client_uri'], logo_uri: [:logo_uri] || ['logo_uri'], tos_uri: [:tos_uri] || ['tos_uri'], policy_uri: [:policy_uri] || ['policy_uri'], contacts: [:contacts] || ['contacts'] ) end |
.extract_auth_method(metadata_data) ⇒ String
Extract token endpoint auth method from metadata
219 220 221 222 |
# File 'lib/mcp_client/auth.rb', line 219 def self.extract_auth_method() [:token_endpoint_auth_method] || ['token_endpoint_auth_method'] || 'none' end |
.from_h(data) ⇒ ClientInfo
Create client info from hash
183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/mcp_client/auth.rb', line 183 def self.from_h(data) = data[:metadata] || data['metadata'] || {} = () new( client_id: data[:client_id] || data['client_id'], client_secret: data[:client_secret] || data['client_secret'], client_id_issued_at: data[:client_id_issued_at] || data['client_id_issued_at'], client_secret_expires_at: data[:client_secret_expires_at] || data['client_secret_expires_at'], metadata: ) end |
Instance Method Details
#client_secret_expired? ⇒ Boolean
Check if client secret is expired
162 163 164 165 166 |
# File 'lib/mcp_client/auth.rb', line 162 def client_secret_expired? return false unless @client_secret_expires_at Time.now.to_i >= @client_secret_expires_at end |
#to_h ⇒ Hash
Convert to hash for serialization
170 171 172 173 174 175 176 177 178 |
# File 'lib/mcp_client/auth.rb', line 170 def to_h { client_id: @client_id, client_secret: @client_secret, client_id_issued_at: @client_id_issued_at, client_secret_expires_at: @client_secret_expires_at, metadata: .to_h }.compact end |