Sha256: 3b486f0bd01dcd73698c95703d854ae18718eac4d2775a79a7a069623ada18e5
Contents?: true
Size: 1.26 KB
Versions: 9
Compression:
Stored size: 1.26 KB
Contents
require 'devise/strategies/base' module Devise module Strategies class Oauth2GrantTypeStrategy < Authenticatable def store? false end def valid? params[:controller] == 'devise/oauth2_providable/tokens' && request.post? && params[:grant_type] == grant_type end # defined by subclass def grant_type end # defined by subclass def authenticate_grant_type(client) end def authenticate! client_id, client_secret = request.authorization ? 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 end end def oauth_error!(error_code = :invalid_request, description = nil) body = {:error => error_code} description = I18n.t("devise.failure.#{error_code}") unless description body[:error_description] = description if description custom! [400, {'Content-Type' => 'application/json'}, [body.to_json]] throw :warden end end end end
Version data entries
9 entries across 9 versions & 1 rubygems