Module: Doorkeeper::ClientAuthentication

Extended by:
Registry
Defined in:
lib/doorkeeper/client_authentication.rb,
lib/doorkeeper/client_authentication/method.rb,
lib/doorkeeper/client_authentication/registry.rb,
lib/doorkeeper/client_authentication/credentials.rb,
lib/doorkeeper/client_authentication/fallback_method.rb,
lib/doorkeeper/client_authentication/legacy_callable.rb,
lib/doorkeeper/client_authentication/verified_credentials.rb

Overview

Registry of the OAuth client authentication methods (RFC 6749 §2.3) Doorkeeper knows how to process. Each registered method is able to tell whether it matches_request? and how to authenticate it into a Credentials object.

Defined Under Namespace

Modules: Registry Classes: Credentials, FallbackMethod, LegacyCallable, Method, VerifiedCredentials

Constant Summary collapse

DEFAULT_METHODS =

Default ordered client authentication methods (RFC 6749 §2.3) used when client_authentication is not configured.

%i[client_secret_basic client_secret_post none].freeze
LEGACY_NAME_FOR =

Maps the current method names back onto the deprecated client_credentials names so the client_credentials_methods alias can keep returning the legacy symbols that external callers (e.g. doorkeeper-openid_connect) map from. Names without a legacy equivalent (e.g. :none, custom methods) are returned unchanged — consumers that don't recognise them drop them, just as they did before.

{
  client_secret_basic: :from_basic,
  client_secret_post: :from_params,
}.freeze

Class Method Summary collapse

Methods included from Registry

get, register

Class Method Details

.from_legacy_client_credentials(methods) ⇒ Object

Converts a deprecated client_credentials configuration into the client authentication method names / adapters understood by the registry. Unknown values are warned about and dropped; callables are wrapped in a LegacyCallable adapter. :none (public client support) is appended only for :from_params — the sole legacy method that accepted a bare client_id without a secret — so a Basic-only configuration is not silently broadened.



69
70
71
72
73
# File 'lib/doorkeeper/client_authentication.rb', line 69

def self.from_legacy_client_credentials(methods)
  converted = methods.filter_map { |method| legacy_client_credential(method) }
  converted.push(:none) if methods.include?(:from_params)
  converted
end

.to_legacy_client_credentials_names(methods) ⇒ Object

Converts resolved Method objects into the legacy client_credentials symbol names for the deprecated client_credentials_methods alias.



35
36
37
# File 'lib/doorkeeper/client_authentication.rb', line 35

def self.to_legacy_client_credentials_names(methods)
  methods.map { |method| LEGACY_NAME_FOR.fetch(method.name, method.name) }
end