Module: Coca

Defined in:
lib/coca/auth_cookie.rb,
lib/coca.rb,
lib/coca/engine.rb,
lib/coca/version.rb,
lib/coca/delegate.rb,
app/helpers/coca/application_helper.rb,
app/controllers/coca/authentications_controller.rb

Overview

Based on the same class in devise-login-cookie by pda github.com/pda/devise-login-cookie

Defined Under Namespace

Modules: ApplicationHelper Classes: AuthCookie, AuthenticationsController, Delegate, Engine

Constant Summary collapse

VERSION =
"0.1.0"
@@masters =
[]
@@servants =
[]
:all
@@check_source =
true
@@require_https =
true
@@propagate_updates =
false
@@token_ttl =
1800
@@secret =
"Unset"
@@debug =
true

Class Method Summary collapse

Class Method Details

.add_master(name, &block) ⇒ Object



37
38
39
# File 'lib/coca.rb', line 37

def add_master(name, &block)
  @@masters.push Coca::Delegate.new(name, &block)
end

.add_servant(name, &block) ⇒ Object



41
42
43
# File 'lib/coca.rb', line 41

def add_servant(name, &block)
  @@servants.push Coca::Delegate.new(name, &block)
end

.valid_master?(referer, key) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/coca.rb', line 49

def valid_master?(referer, key)
  masters.find { |master| master.valid_referer?(referer) && valid_secret?(key) }
end

.valid_secret?(key) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/coca.rb', line 53

def valid_secret?(key)
  !!key && !key.blank? && key == Coca.secret
end

.valid_servant?(referer, key) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/coca.rb', line 45

def valid_servant?(referer, key)
  servants.find { |servant| servant.valid_referer?(referer) && valid_secret?(key) }
end