Class: RubyLLM::MCP::Auth::PKCE
- Inherits:
-
Object
- Object
- RubyLLM::MCP::Auth::PKCE
- Defined in:
- lib/ruby_llm/mcp/auth.rb
Overview
Proof Key for Code Exchange (PKCE) implementation (RFC 7636) Required for OAuth 2.1 security
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
Deserialize from hash.
Instance Method Summary collapse
-
#initialize ⇒ PKCE
constructor
A new instance of PKCE.
-
#to_h ⇒ Hash
Serialize to hash.
Constructor Details
#initialize ⇒ PKCE
Returns a new instance of PKCE.
309 310 311 312 313 |
# File 'lib/ruby_llm/mcp/auth.rb', line 309 def initialize @code_verifier = generate_code_verifier @code_challenge = generate_code_challenge(@code_verifier) @code_challenge_method = "S256" # SHA256 - only secure method for OAuth 2.1 end |
Instance Attribute Details
#code_challenge ⇒ Object (readonly)
Returns the value of attribute code_challenge.
307 308 309 |
# File 'lib/ruby_llm/mcp/auth.rb', line 307 def code_challenge @code_challenge end |
#code_challenge_method ⇒ Object (readonly)
Returns the value of attribute code_challenge_method.
307 308 309 |
# File 'lib/ruby_llm/mcp/auth.rb', line 307 def code_challenge_method @code_challenge_method end |
#code_verifier ⇒ Object (readonly)
Returns the value of attribute code_verifier.
307 308 309 |
# File 'lib/ruby_llm/mcp/auth.rb', line 307 def code_verifier @code_verifier end |
Class Method Details
.from_h(data) ⇒ PKCE
Deserialize from hash
328 329 330 331 332 333 334 335 |
# File 'lib/ruby_llm/mcp/auth.rb', line 328 def self.from_h(data) pkce = allocate pkce.instance_variable_set(:@code_verifier, data[:code_verifier] || data["code_verifier"]) pkce.instance_variable_set(:@code_challenge, data[:code_challenge] || data["code_challenge"]) pkce.instance_variable_set(:@code_challenge_method, data[:code_challenge_method] || data["code_challenge_method"] || "S256") pkce end |
Instance Method Details
#to_h ⇒ Hash
Serialize to hash
317 318 319 320 321 322 323 |
# File 'lib/ruby_llm/mcp/auth.rb', line 317 def to_h { code_verifier: @code_verifier, code_challenge: @code_challenge, code_challenge_method: @code_challenge_method } end |