Class: Warden::OAuth2::Strategies::Token

Inherits:
Base
  • Object
show all
Defined in:
lib/warden/oauth2/strategies/token.rb

Direct Known Subclasses

Bearer

Instance Method Summary collapse

Methods inherited from Base

#store?

Instance Method Details

#authenticate!Object


11
12
13
14
15
16
17
18
19
# File 'lib/warden/oauth2/strategies/token.rb', line 11

def authenticate!
  if token
    fail! "invalid_token" and return if token.respond_to?(:expired?) && token.expired?
    fail! "insufficient_scope" and return if scope && token.respond_to?(:scope?) && !token.scope?(scope)
    success! token
  else
    fail! "invalid_request" and return unless token
  end
end

#error_statusObject


29
30
31
32
33
34
35
36
# File 'lib/warden/oauth2/strategies/token.rb', line 29

def error_status
  case message
    when "invalid_token" then 401
    when "insufficient_scope" then 403
    when "invalid_request" then 400
    else 400
  end
end

#tokenObject


21
22
23
# File 'lib/warden/oauth2/strategies/token.rb', line 21

def token
  Warden::OAuth2.config.token_model.locate(token_string)
end

#token_stringObject

Raises:

  • (NotImplementedError)

25
26
27
# File 'lib/warden/oauth2/strategies/token.rb', line 25

def token_string
  raise NotImplementedError
end

#valid?Boolean

Returns:

  • (Boolean)

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

def valid?
  !!token_string
end