Class: TDiary::Rack::Auth::OmniAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/tdiary/rack/auth/omniauth.rb,
lib/tdiary/rack/auth/omniauth/authorization.rb

Defined Under Namespace

Classes: Authorization, NoStrategyFoundError

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ OmniAuth

Returns a new instance of OmniAuth.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tdiary/rack/auth/omniauth.rb', line 16

def initialize(app)
	provider = enabled_providers.first
	unless provider
		raise NoStrategyFoundError.new("Not found any strategies. Write the omniauth strategy in your Gemfile.local.")
	end

	@app = ::Rack::Builder.new(app) {
		use TDiary::Rack::Session
	}.tap {|builder|
		builder.instance_eval(&self.class.provider_procs[provider])
	}.to_app
end

Class Attribute Details

.provider_procsObject (readonly)

Returns the value of attribute provider_procs.



9
10
11
# File 'lib/tdiary/rack/auth/omniauth.rb', line 9

def provider_procs
  @provider_procs
end

Class Method Details

.add_provider(name, &block) ⇒ Object



12
13
14
# File 'lib/tdiary/rack/auth/omniauth.rb', line 12

def self.add_provider(name, &block)
	@provider_procs[name] = block
end

Instance Method Details

#call(env) ⇒ Object



29
30
31
# File 'lib/tdiary/rack/auth/omniauth.rb', line 29

def call(env)
	@app.call(env)
end