Class: Devise::Strategies::Oauth2GrantTypeStrategy
- Inherits:
-
Authenticatable
- Object
- Authenticatable
- Devise::Strategies::Oauth2GrantTypeStrategy
- Defined in:
- lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb
Direct Known Subclasses
Oauth2AuthorizationCodeGrantTypeStrategy, Oauth2PasswordGrantTypeStrategy, Oauth2RefreshTokenGrantTypeStrategy
Instance Method Summary collapse
- #authenticate! ⇒ Object
-
#authenticate_grant_type(client) ⇒ Object
defined by subclass.
-
#grant_type ⇒ Object
defined by subclass.
-
#oauth_error!(error_code = :invalid_request, description = nil) ⇒ Object
return custom error response in accordance with the oauth spec see tools.ietf.org/html/draft-ietf-oauth-v2-16#section-4.3.
- #valid? ⇒ Boolean
Instance Method Details
#authenticate! ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb', line 18 def authenticate! client_id, client_secret = request. ? decode_credentials : [params[:client_id], params[:client_secret]] client = Devise::Oauth2Providable::Client.find_by_identifier client_id if client && client.secret == client_secret env[Devise::Oauth2Providable::CLIENT_ENV_REF] = client authenticate_grant_type(client) else oauth_error! :invalid_client, 'invalid client credentials' end end |
#authenticate_grant_type(client) ⇒ Object
defined by subclass
15 16 |
# File 'lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb', line 15 def authenticate_grant_type(client) end |
#grant_type ⇒ Object
defined by subclass
11 12 |
# File 'lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb', line 11 def grant_type end |
#oauth_error!(error_code = :invalid_request, description = nil) ⇒ Object
return custom error response in accordance with the oauth spec see tools.ietf.org/html/draft-ietf-oauth-v2-16#section-4.3
31 32 33 34 35 36 |
# File 'lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb', line 31 def oauth_error!(error_code = :invalid_request, description = nil) body = {:error => error_code} body[:error_description] = description if description custom! [400, {'Content-Type' => 'application/json'}, [body.to_json]] throw :warden end |
#valid? ⇒ Boolean
6 7 8 |
# File 'lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb', line 6 def valid? params[:controller] == 'devise/oauth2_providable/tokens' && request.post? && params[:grant_type] == grant_type end |