Sha256: 20a443e446bac2b7ddd1ec9092bb4efbc40bc2a68812d81154a7691209552b71

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

# stdlib
require "uri"

# External libraries
require "openid" # gem ruby-openid2
require "rack/openid"

module OpenIdAuthentication
  module Middleware
    class << self
      # middleware creation
      def new(app)
        if store.nil?
          OpenID::Util.logger.warn("OpenIdAuthentication.store is nil. Using in-memory store.")
        end

        ::Rack::OpenID.new(app, store)
      end

      def store
        @@store
      end

      def store=(*store_option)
        storage, *args = *[store_option].flatten

        @@store = case storage
        when :memory
          require "openid/store/memory"
          OpenID::Store::Memory.new
        when :file
          require "openid/store/filesystem"
          OpenID::Store::Filesystem.new(Rails.root.join("tmp/openids"))
        when :memcache
          require "dalli"
          require "openid/store/memcache"
          OpenID::Store::Memcache.new(Dalli::Client.new(args))
        else
          storage
        end
      end
    end

    self.store = nil
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
open_id_authentication-2.0.2 lib/open_id_authentication/middleware.rb
open_id_authentication-2.0.1 lib/open_id_authentication/middleware.rb
open_id_authentication2-2.0.0 lib/open_id_authentication/middleware.rb