Sha256: d05a4a0fdc93398e82cfc6a3145d6b67997e6686afd2e7931ac22deceb26cf9f

Contents?: true

Size: 872 Bytes

Versions: 6

Compression:

Stored size: 872 Bytes

Contents

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

          def initialize(env)
            super
            verify_required_params!
            @client_id = params['client_id']
            @scope = Array(params['scope'].to_s.split(' '))
          end

          def required_params
            [:client_id]
          end

          def verify_required_params!
            missing_params = []
            required_params.each do |key|
              missing_params << key unless params[key.to_s]
            end
            unless missing_params.blank?
              raise BadRequest.new(:invalid_request, "'#{missing_params.join('\', \'')}' required", :state => @state, :redirect_uri => @redirect_uri)
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rack-oauth2-0.1.0 lib/rack/oauth2/server/abstract/request.rb
rack-oauth2-0.0.9 lib/rack/oauth2/server/abstract/request.rb
rack-oauth2-0.0.8 lib/rack/oauth2/server/abstract/request.rb
rack-oauth2-0.0.7 lib/rack/oauth2/server/abstract/request.rb
rack-oauth2-0.0.6 lib/rack/oauth2/server/abstract/request.rb
rack-oauth2-0.0.5 lib/rack/oauth2/server/abstract/request.rb