Module: Warden::OAuth::StrategyBuilder

Extended by:
StrategyBuilder
Included in:
Strategy, StrategyBuilder
Defined in:
lib/warden_oauth/strategy_builder.rb

Overview

Handles the creation an registration of OAuth strategies based on configuration parameters via the Warden::Manager.oauth method

Instance Method Summary collapse

Instance Method Details

#access_token_user_finder(&blk) ⇒ Object

Defines the user finder from the access_token for the strategy, receives a block that will be invoked each time you want to find an user via an access_token in your system.

Parameters:

  • blk

    Block that recieves the access_token as a parameter and will return a user or nil



19
20
21
# File 'lib/warden_oauth/strategy_builder.rb', line 19

def access_token_user_finder(&blk)
  define_method(:_find_user_by_access_token, &blk)
end

#build(keyword, config) ⇒ Object

Manages the creation and registration of the OAuth strategy specified on the keyword

Parameters:

  • name (Symbol)

    of the oauth service

  • configuration (Walruz::Config)

    specified on the declaration of the oauth service



30
31
32
33
34
35
36
37
38
# File 'lib/warden_oauth/strategy_builder.rb', line 30

def build(keyword, config)
  strategy_class = self.create_oauth_strategy_class(keyword)
  self.register_oauth_strategy_class(keyword, strategy_class)
  self.set_oauth_service_info(strategy_class, config)
  # adding the access_token_user_finder to the strategy
  if self.access_token_user_finders.include?(keyword)
    strategy_class.access_token_user_finder(&self.access_token_user_finders[keyword])
  end
end