Class: MCPClient::Auth::PKCE
- Inherits:
-
Object
- Object
- MCPClient::Auth::PKCE
- Defined in:
- lib/mcp_client/auth.rb
Overview
PKCE (Proof Key for Code Exchange) helper
Instance Attribute Summary collapse
-
#code_challenge ⇒ Object
readonly
Returns the value of attribute code_challenge.
-
#code_challenge_method ⇒ Object
readonly
Returns the value of attribute code_challenge_method.
-
#code_verifier ⇒ Object
readonly
Returns the value of attribute code_verifier.
Class Method Summary collapse
-
.from_h(data) ⇒ PKCE
Create PKCE instance from hash.
Instance Method Summary collapse
-
#initialize(code_verifier: nil, code_challenge: nil, code_challenge_method: nil) ⇒ PKCE
constructor
Generate PKCE parameters.
-
#to_h ⇒ Hash
Convert to hash for serialization.
Constructor Details
#initialize(code_verifier: nil, code_challenge: nil, code_challenge_method: nil) ⇒ PKCE
Generate PKCE parameters
323 324 325 326 327 |
# File 'lib/mcp_client/auth.rb', line 323 def initialize(code_verifier: nil, code_challenge: nil, code_challenge_method: nil) @code_verifier = code_verifier || generate_code_verifier @code_challenge = code_challenge || generate_code_challenge(@code_verifier) @code_challenge_method = code_challenge_method || 'S256' end |
Instance Attribute Details
#code_challenge ⇒ Object (readonly)
Returns the value of attribute code_challenge.
317 318 319 |
# File 'lib/mcp_client/auth.rb', line 317 def code_challenge @code_challenge end |
#code_challenge_method ⇒ Object (readonly)
Returns the value of attribute code_challenge_method.
317 318 319 |
# File 'lib/mcp_client/auth.rb', line 317 def code_challenge_method @code_challenge_method end |
#code_verifier ⇒ Object (readonly)
Returns the value of attribute code_verifier.
317 318 319 |
# File 'lib/mcp_client/auth.rb', line 317 def code_verifier @code_verifier end |
Class Method Details
.from_h(data) ⇒ PKCE
Note:
code_challenge_method is optional and defaults to ‘S256’. The code_challenge is not re-validated against code_verifier; callers are expected to provide values from a prior to_h round-trip.
Create PKCE instance from hash
346 347 348 349 350 351 352 353 354 355 |
# File 'lib/mcp_client/auth.rb', line 346 def self.from_h(data) verifier = data[:code_verifier] || data['code_verifier'] challenge = data[:code_challenge] || data['code_challenge'] method = data[:code_challenge_method] || data['code_challenge_method'] raise ArgumentError, 'Missing code_verifier' unless verifier raise ArgumentError, 'Missing code_challenge' unless challenge new(code_verifier: verifier, code_challenge: challenge, code_challenge_method: method) end |
Instance Method Details
#to_h ⇒ Hash
Convert to hash for serialization
331 332 333 334 335 336 337 |
# File 'lib/mcp_client/auth.rb', line 331 def to_h { code_verifier: @code_verifier, code_challenge: @code_challenge, code_challenge_method: @code_challenge_method } end |