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
361 362 363 364 365 |
# File 'lib/mcp_client/auth.rb', line 361 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.
355 356 357 |
# File 'lib/mcp_client/auth.rb', line 355 def code_challenge @code_challenge end |
#code_challenge_method ⇒ Object (readonly)
Returns the value of attribute code_challenge_method.
355 356 357 |
# File 'lib/mcp_client/auth.rb', line 355 def code_challenge_method @code_challenge_method end |
#code_verifier ⇒ Object (readonly)
Returns the value of attribute code_verifier.
355 356 357 |
# File 'lib/mcp_client/auth.rb', line 355 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
384 385 386 387 388 389 390 391 392 393 |
# File 'lib/mcp_client/auth.rb', line 384 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
369 370 371 372 373 374 375 |
# File 'lib/mcp_client/auth.rb', line 369 def to_h { code_verifier: @code_verifier, code_challenge: @code_challenge, code_challenge_method: @code_challenge_method } end |