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
Returns a new instance of ClientInfo.
128 129 130 131 132 133 134 135 |
# File 'lib/mcp_client/auth.rb', line 128 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.
121 122 123 |
# File 'lib/mcp_client/auth.rb', line 121 def client_id @client_id end |
#client_id_issued_at ⇒ Object (readonly)
Returns the value of attribute client_id_issued_at.
121 122 123 |
# File 'lib/mcp_client/auth.rb', line 121 def client_id_issued_at @client_id_issued_at end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
121 122 123 |
# File 'lib/mcp_client/auth.rb', line 121 def client_secret @client_secret end |
#client_secret_expires_at ⇒ Object (readonly)
Returns the value of attribute client_secret_expires_at.
121 122 123 |
# File 'lib/mcp_client/auth.rb', line 121 def client_secret_expires_at @client_secret_expires_at end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
121 122 123 |
# File 'lib/mcp_client/auth.rb', line 121 def end |
Class Method Details
.build_metadata_from_hash(metadata_data) ⇒ ClientMetadata
Build ClientMetadata from hash data
176 177 178 179 180 181 182 183 184 185 |
# File 'lib/mcp_client/auth.rb', line 176 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'] ) end |
.extract_auth_method(metadata_data) ⇒ String
Extract token endpoint auth method from metadata
190 191 192 193 |
# File 'lib/mcp_client/auth.rb', line 190 def self.extract_auth_method() [:token_endpoint_auth_method] || ['token_endpoint_auth_method'] || 'none' end |
.from_h(data) ⇒ ClientInfo
Create client info from hash
160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/mcp_client/auth.rb', line 160 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
139 140 141 142 143 |
# File 'lib/mcp_client/auth.rb', line 139 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
147 148 149 150 151 152 153 154 155 |
# File 'lib/mcp_client/auth.rb', line 147 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 |