Sha256: d97fa8849319684ead52e207da98fa5ee4af127add7d29d80864ef8a3ad6803f

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

module Rack
  module OAuth2
    module Server
      module Abstract
        class Request < Rack::Request
          attr_accessor :client_id, :scope

          def initialize(env)
            super
            missing_params = verify_required_params
            @client_id ||= params['client_id']
            @scope = Array(params['scope'].to_s.split(' '))
            missing_params << :client_id if @client_id.blank?
            unless missing_params.blank?
              invalid_request!("'#{missing_params.join('\', \'')}' required.", :state => @state, :redirect_uri => @redirect_uri)
            end
            if params['client_id'].present? && @client_id != params['client_id']
              invalid_client!("Multiple client credentials are provided.")
            end
          end

          def required_params
            []
          end

          def verify_required_params
            missing_params = []
            required_params.each do |key|
              missing_params << key unless params[key.to_s]
            end
            missing_params
          end

        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rack-oauth2-0.2.2.1 lib/rack/oauth2/server/abstract/request.rb
rack-oauth2-0.2.2 lib/rack/oauth2/server/abstract/request.rb
rack-oauth2-0.2.1 lib/rack/oauth2/server/abstract/request.rb
rack-oauth2-0.2.0 lib/rack/oauth2/server/abstract/request.rb