Sha256: 4e780c27f96881e5af13c96d157c6b625198d2708dd38b30ffcb1d6c1fa051d9

Contents?: true

Size: 905 Bytes

Versions: 1

Compression:

Stored size: 905 Bytes

Contents

require 'uri'
require 'openid'
require 'rack/openid'

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

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

    def self.store
      @@store
    end

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

      @@store = case store
      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 'memcache'
        require 'openid/store/memcache'
        OpenID::Store::Memcache.new(MemCache.new(args))
      else
        store
      end
    end

    self.store = nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
open_id_authentication-1.2.0 lib/open_id_authentication/middleware.rb