Class: Warden::OAuth2::Strategies::Bearer

Inherits:
Token
  • Object
show all
Defined in:
lib/warden/oauth2/strategies/bearer.rb

Instance Method Summary collapse

Methods inherited from Token

#authenticate!, #error_status, #token

Methods inherited from Base

#error_status, #store?

Instance Method Details

#token_stringObject


11
12
13
# File 'lib/warden/oauth2/strategies/bearer.rb', line 11

def token_string
  token_string_from_header || token_string_from_request_params
end

#token_string_from_headerObject


15
16
17
18
19
20
21
22
# File 'lib/warden/oauth2/strategies/bearer.rb', line 15

def token_string_from_header
  Rack::Auth::AbstractRequest::AUTHORIZATION_KEYS.each do |key|
    if env.key?(key) && token_string = env[key][/^Bearer (.*)/, 1]
      return token_string
    end
  end
  nil
end

#token_string_from_request_paramsObject


24
25
26
# File 'lib/warden/oauth2/strategies/bearer.rb', line 24

def token_string_from_request_params
  params[:access_token]
end

#valid?Boolean

Returns:

  • (Boolean)

7
8
9
# File 'lib/warden/oauth2/strategies/bearer.rb', line 7

def valid?
  !!token_string
end