Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6514

Show
Ignore:
Timestamp:
04/11/07 19:58:30 (1 year ago)
Author:
david
Message:

Added a new default database-backed store after experiencing trouble with the filestore on NFS. The file store is still available as an option [DHH]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/open_id_authentication/CHANGELOG

    r6331 r6514  
     1* Added a new default database-backed store after experiencing trouble with the filestore on NFS. The file store is still available as an option [DHH] 
     2 
    13* Added normalize_url and applied it to all operations going through the plugin [DHH] 
    24 
  • plugins/open_id_authentication/lib/open_id_authentication.rb

    r6452 r6514  
    11module OpenIdAuthentication 
    22  OPEN_ID_AUTHENTICATION_DIR = RAILS_ROOT + "/tmp/openids" 
     3   
     4  @@store = :db 
     5  mattr_accessor :store 
    36 
    47  class Result 
     
    107110 
    108111    def open_id_consumer 
    109       OpenID::Consumer.new(session, OpenID::FilesystemStore.new(OPEN_ID_AUTHENTICATION_DIR)) 
     112      OpenID::Consumer.new(session, open_id_store) 
     113    end 
     114     
     115    def open_id_store 
     116      case store 
     117      when :db  : OpenIdAuthentication::DbStore.new 
     118      when :file: OpenID::FilesystemStore.new(OPEN_ID_AUTHENTICATION_DIR) 
     119      else 
     120        raise "Unknown store: #{store}" 
     121      end 
    110122    end 
    111123 
  • plugins/open_id_authentication/README

    r6331 r6514  
    1515============= 
    1616 
    17 OpenID authentication uses the session, so be sure that you haven't turned that off. It also relies on tmp/openids 
    18 being present in RAILS_ROOT. The install.rb should install that automatically as you get the plugin, but if not, be 
    19 sure to do that yourself. 
     17OpenID authentication uses the session, so be sure that you haven't turned that off. It also relies on a number of 
     18database tables to store the authentication keys. So you'll have to run the migration to create these before you get started: 
     19 
     20  rake open_id_authentication:db:create 
     21 
     22Alternatively, you can use the file-based store, which just relies on on tmp/openids being present in RAILS_ROOT. But be aware that this store only works if you have a single application server. And it's not safe to use across NFS. It's recommended that you use the database store if at all possible. To use the file-based store, you'll also have to add this line to your config/environment.rb: 
     23 
     24  OpenIdAuthentication.store = :file 
    2025 
    2126This particular plugin also relies on the fact that the authentication action allows for both POST and GET operations. 
  • plugins/open_id_authentication/tasks/open_id_authentication_tasks.rake

    r6245 r6514  
    1 # desc "Explaining what the task does" 
    2 # task :open_id_authentication do 
    3 #   # Task goes here 
    4 # end 
     1namespace :open_id_authentication do 
     2  namespace :db do 
     3    desc "Creates authentication tables for use with OpenIdAuthentication" 
     4    task :create => :environment do 
     5      raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations? 
     6      require 'rails_generator' 
     7      require 'rails_generator/scripts/generate' 
     8      Rails::Generator::Scripts::Generate.new.run([ "open_id_authentication_tables", "open_id_authentication_tables" ]) 
     9    end 
     10 
     11    desc "Clear the authentication tables" 
     12    task :clear => :environment do 
     13      OpenIdAuthentication::DbStore.gc 
     14    end 
     15  end 
     16end