Module: Doorkeeper::Request
- Defined in:
- lib/doorkeeper.rb,
lib/doorkeeper/request.rb,
lib/doorkeeper/request/code.rb,
lib/doorkeeper/request/token.rb,
lib/doorkeeper/request/password.rb,
lib/doorkeeper/request/strategy.rb,
lib/doorkeeper/request/refresh_token.rb,
lib/doorkeeper/request/authorization_code.rb,
lib/doorkeeper/request/client_credentials.rb
Defined Under Namespace
Classes: AuthorizationCode, ClientCredentials, Code, Password, RefreshToken, Strategy, Token
Class Method Summary collapse
- .authorization_strategy(response_type) ⇒ Object
-
.client_authentication_method(request) ⇒ Object
Detect the OAuth client authentication method (RFC 6749 §2.3) that the given request uses.
- .token_strategy(grant_type) ⇒ Object
Class Method Details
.authorization_strategy(response_type) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/doorkeeper/request.rb', line 28 def (response_type) grant_flow = .detect do |flow| flow.matches_response_type?(response_type) end if grant_flow grant_flow.response_type_strategy else # [NOTE]: this will be removed in a newer versions of Doorkeeper. # For retro-compatibility only build_fallback_strategy_class(response_type) end end |
.client_authentication_method(request) ⇒ Object
Detect the OAuth client authentication method (RFC 6749 §2.3) that the given request uses. Returns the matching method's strategy (not the registry's Method wrapper), or FallbackMethod when none matches (which authenticates to no credentials).
Raises Errors::MultipleClientAuthMethods when the request itself
uses more than one client authentication method, since RFC 6749 §2.3
forbids that (see validate_client_authentication!).
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/doorkeeper/request.rb', line 14 def client_authentication_method(request) validate_client_authentication!(request) authentication_method = client_authentication_methods.detect do |method| method.matches_request?(request) end if authentication_method authentication_method.strategy else Doorkeeper::ClientAuthentication::FallbackMethod end end |
.token_strategy(grant_type) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/doorkeeper/request.rb', line 42 def token_strategy(grant_type) raise Errors::MissingRequiredParameter, :grant_type if grant_type.blank? grant_flow = token_flows.detect do |flow| flow.matches_grant_type?(grant_type) end if grant_flow grant_flow.grant_type_strategy else # [NOTE]: this will be removed in a newer versions of Doorkeeper. # For retro-compatibility only raise Errors::InvalidTokenStrategy unless available.include?(grant_type.to_s) strategy_class = build_fallback_strategy_class(grant_type) raise Errors::InvalidTokenStrategy unless strategy_class strategy_class end end |