Class: Doorkeeper::ClientAuthentication::Method
- Inherits:
-
Object
- Object
- Doorkeeper::ClientAuthentication::Method
- Defined in:
- lib/doorkeeper/client_authentication/method.rb
Overview
Wraps a registered client authentication method, pairing its
registration name with the strategy object that knows how to match
and authenticate a request.
NOTE: the wrapped object is exposed as strategy rather than method on
purpose — an attr_reader :method would shadow Ruby's core
Object#method reflection API and break wrapper.method(:authenticate).
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Instance Method Summary collapse
-
#initialize(name, strategy) ⇒ Method
constructor
A new instance of Method.
-
#uses_shared_secret? ⇒ Boolean
Whether this method authenticates clients with a shared symmetric secret.
Constructor Details
#initialize(name, strategy) ⇒ Method
Returns a new instance of Method.
17 18 19 20 |
# File 'lib/doorkeeper/client_authentication/method.rb', line 17 def initialize(name, strategy) @name = name @strategy = strategy end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/doorkeeper/client_authentication/method.rb', line 13 def name @name end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
13 14 15 |
# File 'lib/doorkeeper/client_authentication/method.rb', line 13 def strategy @strategy end |
Instance Method Details
#uses_shared_secret? ⇒ Boolean
Whether this method authenticates clients with a shared symmetric secret. Callers that must refuse such methods — because no secret can have been established with the client — can ask the registry instead of keeping a hard-coded list of method names.
Strategies may declare this themselves by defining
uses_shared_secret?; for strategies that don't, the registration
name is checked for "client_secret" as a conservative fallback, so an
undeclared method errs on the side of being treated as secret-based.
31 32 33 34 35 36 37 |
# File 'lib/doorkeeper/client_authentication/method.rb', line 31 def uses_shared_secret? if strategy.respond_to?(:uses_shared_secret?) strategy.uses_shared_secret? else name.to_s.include?("client_secret") end end |