Class: Hadley::Authz::Bearer::Strategy

Inherits:
Strategy
  • Object
show all
Defined in:
lib/hadley/authz/bearer.rb

Instance Method Summary collapse

Methods inherited from Strategy

#config

Methods included from StrategyBuilder

#build, #create_strategy, #register_strategy, #set_config

Instance Method Details

#authRack::Aauth::Bearer::Request

Provides access to the bearer token based auth information assiciated with the current request.

Returns:

  • (Rack::Aauth::Bearer::Request)

    The bearer token based auth information assiciated with the current request.



34
35
36
# File 'lib/hadley/authz/bearer.rb', line 34

def auth
  @auth ||= Rack::Auth::Bearer::Request.new(env)
end

#authenticate!(anonymous_allowed = false) ⇒ Object

Authenticates the entity identified by the provided bearer token.



48
49
50
51
52
53
# File 'lib/hadley/authz/bearer.rb', line 48

def authenticate!(anonymous_allowed=false)
  return unauthorized unless auth.provided? and auth.bearer? and auth.token
  user = config.token_store.get(auth.token)
  return unauthorized unless user and (!user[:anonymous] or config.anonymous_allowed)
  success!(user)
end

#store?Boolean

Identifies whether a login using this strategy should be persisted across multiple requests.

Returns:

  • (Boolean)

    true if and only if a login using this strategy should be persistent across multiple requests.

See Also:

  • Warden::Strategies::Base#store?


43
44
45
# File 'lib/hadley/authz/bearer.rb', line 43

def store?
  false
end