Sha256: 4b5fa4a30ebf2de04b89ee063052cc115e4e18f962324d4657302ab584a4e84c

Contents?: true

Size: 1.02 KB

Versions: 38

Compression:

Stored size: 1.02 KB

Contents

module Rack
  module OAuth2
    module Server
      module Rails
        class Authorize < Server::Authorize
          def initialize(app)
            super()
            @app = app
          end

          def _call(env)
            prepare_oauth_env env
            @app.call env
          rescue Rack::OAuth2::Server::Abstract::Error => e
            e.finish
          end

          private

          def prepare_oauth_env(env)
            response_type = response_type_for(
              Server::Authorize::Request.new(env)
            ).new
            response_type._call(env)
            response_type.response.extend ResponseExt
            env[REQUEST]  = response_type.request
            env[RESPONSE] = response_type.response
          rescue Rack::OAuth2::Server::Abstract::Error => e
            env[ERROR] = e
          end

          module ResponseExt
            include Rails::ResponseExt

            def approve!
              super
              finish
            end
          end
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
rack-oauth2-1.13.0.beta lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.12.0 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.11.0 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.10.1 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.10.0 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.9.3 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.9.2 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.9.1 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.9.0 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.8.2 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.8.1 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.8.0 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.7.1 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.7.0 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.6.4 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.6.3 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.6.2 lib/rack/oauth2/server/rails/authorize.rb
rack-oauth2-1.6.1 lib/rack/oauth2/server/rails/authorize.rb