Sha256: 661d2e236bc004c32fa25c4153978c49032048fa952671cb64b083fb712d128c

Contents?: true

Size: 1.15 KB

Versions: 32

Compression:

Stored size: 1.15 KB

Contents

module Rack
  module OAuth2
    module Server
      class Resource
        class Bearer < Resource
          def call(env)
            self.request = Request.new(env)
            super
          end

          private

          class Request < Resource::Request
            def setup!
              tokens = [access_token_in_header, access_token_in_payload].compact
              @access_token = case Array(tokens).size
              when 1
                tokens.first
              else
                invalid_request!('Both Authorization header and payload includes access token.')
              end
              self
            end

            def oauth2?
              (access_token_in_header || access_token_in_payload).present?
            end

            def access_token_in_header
              if @auth_header.provided? && @auth_header.scheme == :bearer
                @auth_header.params
              else
                nil
              end
            end

            def access_token_in_payload
              params['access_token']
            end
          end
        end
      end
    end
  end
end

require 'rack/oauth2/server/resource/bearer/error'

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
rack-oauth2-1.0.0 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.9 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.8 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.7 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.6 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.5 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.4 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.3 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.2 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.1 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.14.0 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.13.0 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.12.2 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.12.1 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.12.0 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.11.0 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.10.1 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.10.0 lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.10.0.alpha lib/rack/oauth2/server/resource/bearer.rb
rack-oauth2-0.9.5 lib/rack/oauth2/server/resource/bearer.rb