Class: Rack::OAuth2::Server::Resource::Bearer::Request

Inherits:
Request
  • Object
show all
Defined in:
lib/rack/oauth2/server/resource/bearer.rb

Instance Attribute Summary

Attributes inherited from Request

#access_token

Instance Method Summary collapse

Methods inherited from Request

#initialize

Constructor Details

This class inherits a constructor from Rack::OAuth2::Server::Resource::Request

Instance Method Details

#access_token_in_headerObject



29
30
31
32
33
34
35
# File 'lib/rack/oauth2/server/resource/bearer.rb', line 29

def access_token_in_header
  if @auth_header.provided? && !@auth_header.parts.first.nil? && @auth_header.scheme.to_s == 'bearer'
    @auth_header.params
  else
    nil
  end
end

#access_token_in_payloadObject



37
38
39
# File 'lib/rack/oauth2/server/resource/bearer.rb', line 37

def access_token_in_payload
  params['access_token']
end

#oauth2?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/rack/oauth2/server/resource/bearer.rb', line 25

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

#setup!Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/rack/oauth2/server/resource/bearer.rb', line 14

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