Sha256: acdd72f273883a181fee1d7c9f279fb5976b95f1bdb4c952dbc7f5fc1f70dc1f

Contents?: true

Size: 1008 Bytes

Versions: 6

Compression:

Stored size: 1008 Bytes

Contents

require 'warden/cookie_session/encrypted_cookie'

class Warden::CookieSession::Strategy < ::Warden::Strategies::Base

  def valid?
    cookies[Warden::CookieSession.config.cookie]
  end

  def store?
    false
  end

  def authenticate!
    key, salt = encrypted_cookie.get
    record = Warden::CookieSession.config.fetch_record(key)
    success!(record) if record && Warden::CookieSession.config.validate_record(record, salt)
  rescue StandardError => e
    logger.warn "Warden::CookieSession::Strategy failed: #{e}"
    fail!(e)
    logger.debug { e.backtrace }
  end

  def self.encrypted_cookie(cookies)
    Warden::CookieSession::EncryptedCookie.new(
      store:  cookies,
      cookie: Warden::CookieSession.config.cookie,
      secret: Warden::CookieSession.config.secret
    )
  end

  def encrypted_cookie
    @encrypted_cookie ||= Warden::CookieSession::Strategy.encrypted_cookie(cookies)
  end

  private

    def logger
      Warden::CookieSession.config.logger || Logger.new(nil)
    end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
warden_cookie_session-0.1.1.19161 lib/warden/cookie_session/strategy.rb
warden_cookie_session-0.1.1.18842 lib/warden/cookie_session/strategy.rb
warden_cookie_session-0.1.0.18828 lib/warden/cookie_session/strategy.rb
warden_cookie_session-0.1.0.18794 lib/warden/cookie_session/strategy.rb
warden_cookie_session-0.1.0.18558 lib/warden/cookie_session/strategy.rb
warden_cookie_session-0.1.0.18557 lib/warden/cookie_session/strategy.rb