Module: Doorkeeper::ClientAuthentication::Registry
- Included in:
- Doorkeeper::ClientAuthentication
- Defined in:
- lib/doorkeeper/client_authentication/registry.rb
Overview
Holds the registered client authentication methods and provides the DSL to register and look them up by name.
Instance Method Summary collapse
-
#get(name) ⇒ Object
[NOTE]: switch to #fetch once the deprecated client_credentials fallbacks are removed.
-
#register(name, method) ⇒ Object
Allows to register a custom OAuth client authentication method so that Doorkeeper could recognize and process it.
Instance Method Details
#get(name) ⇒ Object
[NOTE]: switch to #fetch once the deprecated client_credentials fallbacks are removed.
40 41 42 43 44 |
# File 'lib/doorkeeper/client_authentication/registry.rb', line 40 def get(name) return unless name.respond_to?(:to_sym) registered_methods[name.to_sym] end |
#register(name, method) ⇒ Object
Allows to register a custom OAuth client authentication method so that Doorkeeper could recognize and process it.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/doorkeeper/client_authentication/registry.rb', line 14 def register(name, method) unless name.respond_to?(:to_sym) raise ArgumentError, "client authentication method name must be a Symbol or String, got #{name.inspect}" end unless method.respond_to?(:matches_request?) && method.respond_to?(:authenticate) raise ArgumentError, "client authentication method '#{name}' must respond to " \ "#matches_request? and #authenticate, got #{method.inspect}" end name_key = name.to_sym if registered_methods.key?(name_key) ::Kernel.warn <<~WARNING [DOORKEEPER] '#{name_key}' client authentication strategy is already registered and will be overridden in #{caller(1..1).first} WARNING end registered_methods[name_key] = Doorkeeper::ClientAuthentication::Method.new(name_key, method) end |