Permalink
Browse files

Authlogic & OpenID. OpenID still needs to be plugged into UI.

  • Loading branch information...
jdwyah committed May 20, 2009
1 parent caad283 commit f4252b2a8aad92c513b3d3d14bf9a91ad8eb49b7
Showing with 988 additions and 105 deletions.
  1. +9 −5 app/controllers/user_sessions_controller.rb
  2. +9 −5 app/controllers/users_controller.rb
  3. +0 −2 app/models/user.rb
  4. +1 −3 app/views/layouts/application.html.erb
  5. +0 −8 app/views/users/show.html.haml
  6. +1 −0 config/environment.rb
  7. +25 −0 db/migrate/20090520223643_create_users.rb
  8. +16 −0 db/migrate/20090520223733_create_sessions.rb
  9. +19 −0 db/migrate/20090520223947_add_users_openid_field.rb
  10. +20 −0 db/migrate/20090520224205_add_open_id_authentication_tables.rb
  11. +23 −82 db/schema.rb
  12. +35 −0 vendor/plugins/open_id_authentication/CHANGELOG
  13. +231 −0 vendor/plugins/open_id_authentication/README
  14. +22 −0 vendor/plugins/open_id_authentication/Rakefile
  15. +11 −0 ...uthentication/generators/open_id_authentication_tables/open_id_authentication_tables_generator.rb
  16. +20 −0 ...or/plugins/open_id_authentication/generators/open_id_authentication_tables/templates/migration.rb
  17. +26 −0 ...ns/open_id_authentication/generators/upgrade_open_id_authentication_tables/templates/migration.rb
  18. +11 −0 ...nerators/upgrade_open_id_authentication_tables/upgrade_open_id_authentication_tables_generator.rb
  19. +18 −0 vendor/plugins/open_id_authentication/init.rb
  20. +240 −0 vendor/plugins/open_id_authentication/lib/open_id_authentication.rb
  21. +9 −0 vendor/plugins/open_id_authentication/lib/open_id_authentication/association.rb
  22. +55 −0 vendor/plugins/open_id_authentication/lib/open_id_authentication/db_store.rb
  23. +5 −0 vendor/plugins/open_id_authentication/lib/open_id_authentication/nonce.rb
  24. +23 −0 vendor/plugins/open_id_authentication/lib/open_id_authentication/request.rb
  25. +20 −0 vendor/plugins/open_id_authentication/lib/open_id_authentication/timeout_fixes.rb
  26. +30 −0 vendor/plugins/open_id_authentication/tasks/open_id_authentication_tasks.rake
  27. +32 −0 vendor/plugins/open_id_authentication/test/normalize_test.rb
  28. +46 −0 vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb
  29. +14 −0 vendor/plugins/open_id_authentication/test/status_test.rb
  30. +17 −0 vendor/plugins/open_id_authentication/test/test_helper.rb
@@ -8,12 +8,16 @@ def new
def create
@user_session = UserSession.new(params[:user_session])
- if @user_session.save
- flash[:notice] = "Login successful!"
- redirect_back_or_default account_url
- else
- render :action => :new
+
+ @user_session.save do |result|
+ if result
+ flash[:notice] = "Login successful!"
+ redirect_back_or_default account_url
+ else
+ render :action => :new
+ end
end
+
end
def destroy
@@ -8,12 +8,16 @@ def new
def create
@user = User.new(params[:user])
- if @user.save
- flash[:notice] = "Account registered!"
- redirect_back_or_default account_url
- else
- render :action => :new
+
+ @user.save do |result|
+ if result
+ flash[:notice] = "Account registered!"
+ redirect_back_or_default account_url
+ else
+ render :action => :new
+ end
end
+
end
def show
View
@@ -2,8 +2,6 @@ class User < ActiveRecord::Base
acts_as_authentic do |c|
c.crypto_provider = Authlogic::CryptoProviders::BCrypt
- c.transition_from_crypto_providers = Authlogic::CryptoProviders::MD5
end
- has_many :topics
end
@@ -10,9 +10,7 @@
</head>
<body>
-<span style="float: right; text-align: right;"><%= link_to "Source code", "http://github.com/binarylogic/authlogic_example" %> | <%= link_to "Setup tutorial", "http://www.binarylogic.com/2008/11/3/tutorial-authlogic-basic-setup" %> | <%= link_to "Password reset tutorial", "http://www.binarylogic.com/2008/11/16/tutorial-reset-passwords-with-authlogic" %><br />
-<%= link_to "OpenID tutorial", "http://www.binarylogic.com/2008/11/21/tutorial-using-openid-with-authlogic" %> | <%= link_to "Authlogic Repo", "http://github.com/binarylogic/authlogic" %> | <%= link_to "Authlogic Doc", "http://authlogic.rubyforge.org/" %></span>
-<h1>Authlogic Example App</h1>
+ <h1>MyHippocampus</h1>
<%= pluralize User.logged_in.count, "user" %> currently logged in<br /> <!-- This based on last_request_at, if they were active < 10 minutes they are logged in -->
<br />
<br />
@@ -1,10 +1,2 @@
%h1
== Name #{@user.login}
-%ol
- - for topic in @user.topics
- %li
- == Title #{topic.id} #{topic.title} Type #{topic.type}
- %ol
- - for has in topic.topics
- %li
- == !!!!!Has #{has.title} type #{has.type}
View
@@ -21,6 +21,7 @@
# config.gem "aws-s3", :lib => "aws/s3"
config.gem "haml", :version => '2.0.9'
config.gem "authlogic", :version => "2.0.5"
+ config.gem "authlogic-oid", :lib => "authlogic_openid", :version => '1.0.3'
config.gem "bcrypt-ruby", :lib => 'bcrypt', :version => "2.0.5"
# Only load the plugins named here, in the order given (default is alphabetical).
@@ -0,0 +1,25 @@
+class CreateUsers < ActiveRecord::Migration
+ def self.up
+ create_table :users do |t|
+ t.timestamps
+ t.string :login, :null => false
+ t.string :crypted_password, :null => false
+ t.string :password_salt, :null => false
+ t.string :persistence_token, :null => false
+ t.integer :login_count, :default => 0, :null => false
+ t.datetime :last_request_at
+ t.datetime :last_login_at
+ t.datetime :current_login_at
+ t.string :last_login_ip
+ t.string :current_login_ip
+ end
+
+ add_index :users, :login
+ add_index :users, :persistence_token
+ add_index :users, :last_request_at
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
@@ -0,0 +1,16 @@
+class CreateSessions < ActiveRecord::Migration
+ def self.up
+ create_table :sessions do |t|
+ t.string :session_id, :null => false
+ t.text :data
+ t.timestamps
+ end
+
+ add_index :sessions, :session_id
+ add_index :sessions, :updated_at
+ end
+
+ def self.down
+ drop_table :sessions
+ end
+end
@@ -0,0 +1,19 @@
+class AddUsersOpenidField < ActiveRecord::Migration
+ def self.up
+ add_column :users, :openid_identifier, :string
+ add_index :users, :openid_identifier
+
+ change_column :users, :login, :string, :default => nil, :null => true
+ change_column :users, :crypted_password, :string, :default => nil, :null => true
+ change_column :users, :password_salt, :string, :default => nil, :null => true
+ end
+
+ def self.down
+ remove_column :users, :openid_identifier
+
+ [:login, :crypted_password, :password_salt].each do |field|
+ User.all(:conditions => "#{field} is NULL").each { |user| user.update_attribute(field, "") if user.send(field).nil? }
+ change_column :users, field, :string, :default => "", :null => false
+ end
+ end
+end
@@ -0,0 +1,20 @@
+class AddOpenIdAuthenticationTables < ActiveRecord::Migration
+ def self.up
+ create_table :open_id_authentication_associations, :force => true do |t|
+ t.integer :issued, :lifetime
+ t.string :handle, :assoc_type
+ t.binary :server_url, :secret
+ end
+
+ create_table :open_id_authentication_nonces, :force => true do |t|
+ t.integer :timestamp, :null => false
+ t.string :server_url, :null => true
+ t.string :salt, :null => false
+ end
+ end
+
+ def self.down
+ drop_table :open_id_authentication_associations
+ drop_table :open_id_authentication_nonces
+ end
+end
View
@@ -9,97 +9,41 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20090330212701) do
+ActiveRecord::Schema.define(:version => 20090520224205) do
- create_table "invitations", :force => true do |t|
- t.string "email"
- t.string "user_agent"
- t.string "referer"
- t.string "host"
- t.integer "inviter_user_id"
- t.integer "signup_user_id"
- t.string "random_key"
- t.integer "sent_email_ok"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
- create_table "occurrences", :force => true do |t|
- t.string "type"
- t.integer "user_id"
- t.string "title"
- t.text "data"
- t.datetime "updated_at"
- t.datetime "created_at"
- t.string "uri"
- t.integer "mind_tree_id"
+ create_table "open_id_authentication_associations", :force => true do |t|
+ t.integer "issued"
+ t.integer "lifetime"
+ t.string "handle"
+ t.string "assoc_type"
+ t.binary "server_url"
+ t.binary "secret"
end
- create_table "subjects", :force => true do |t|
- t.string "type"
- t.string "foreign_id"
- t.string "name"
+ create_table "open_id_authentication_nonces", :force => true do |t|
+ t.integer "timestamp", :null => false
+ t.string "server_url"
+ t.string "salt", :null => false
end
- create_table "subscriptions", :force => true do |t|
- t.string "description"
- t.float "price"
- t.integer "max_topics"
+ create_table "sessions", :force => true do |t|
+ t.string "session_id", :null => false
+ t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
end
- create_table "topics", :force => true do |t|
- t.string "type"
- t.integer "user_id"
- t.string "title"
- t.datetime "updated_at"
- t.datetime "created_at"
- t.integer "public_visible"
- t.integer "subject"
- t.integer "subject_id"
- t.integer "latitude"
- t.integer "longitude"
- t.text "data"
- t.string "uri"
- t.string "title_lower"
- end
-
- create_table "topics_associations", :force => true do |t|
- t.integer "association_id"
- t.integer "topic_id"
- end
-
- create_table "topics_occurrences", :force => true do |t|
- t.integer "occurrence_id"
- t.integer "topic_id"
- t.integer "latitude"
- t.integer "longitude"
- end
-
- create_table "topics_topics", :force => true do |t|
- t.integer "from_id"
- t.integer "to_id"
- t.integer "latitude"
- t.integer "longitude"
- end
+ add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
+ add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
create_table "users", :force => true do |t|
- t.string "login"
- t.string "crypted_password"
- t.string "email"
- t.integer "enabled"
- t.integer "supervisor"
- t.integer "invitations"
- t.integer "subscription_id"
- t.string "paypal_id"
- t.date "last_delicious_import"
- t.date "last_google_apps_import"
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "login"
+ t.string "crypted_password"
t.string "password_salt"
- t.string "persistence_token"
- t.integer "login_count"
+ t.string "persistence_token", :null => false
+ t.integer "login_count", :default => 0, :null => false
t.datetime "last_request_at"
t.datetime "last_login_at"
t.datetime "current_login_at"
@@ -108,12 +52,9 @@
t.string "openid_identifier"
end
+ add_index "users", ["last_request_at"], :name => "index_users_on_last_request_at"
add_index "users", ["login"], :name => "index_users_on_login"
add_index "users", ["openid_identifier"], :name => "index_users_on_openid_identifier"
-
- create_table "users_topics", :force => true do |t|
- t.integer "topic_id"
- t.integer "user_id"
- end
+ add_index "users", ["persistence_token"], :name => "index_users_on_persistence_token"
end
@@ -0,0 +1,35 @@
+* Fake HTTP method from OpenID server since they only support a GET. Eliminates the need to set an extra route to match the server's reply. [Josh Peek]
+
+* OpenID 2.0 recommends that forms should use the field name "openid_identifier" rather than "openid_url" [Josh Peek]
+
+* Return open_id_response.display_identifier to the application instead of .endpoints.claimed_id. [nbibler]
+
+* Add Timeout protection [Rick]
+
+* An invalid identity url passed through authenticate_with_open_id will no longer raise an InvalidOpenId exception. Instead it will return Result[:missing] to the completion block.
+
+* Allow a return_to option to be used instead of the requested url [Josh Peek]
+
+* Updated plugin to use Ruby OpenID 2.x.x [Josh Peek]
+
+* Tied plugin to ruby-openid 1.1.4 gem until we can make it compatible with 2.x [DHH]
+
+* Use URI instead of regexps to normalize the URL and gain free, better matching #8136 [dkubb]
+
+* Allow -'s in #normalize_url [Rick]
+
+* remove instance of mattr_accessor, it was breaking tests since they don't load ActiveSupport. Fix Timeout test [Rick]
+
+* Throw a InvalidOpenId exception instead of just a RuntimeError when the URL can't be normalized [DHH]
+
+* Just use the path for the return URL, so extra query parameters don't interfere [DHH]
+
+* 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]
+
+* Added normalize_url and applied it to all operations going through the plugin [DHH]
+
+* Removed open_id? as the idea of using the same input box for both OpenID and username has died -- use using_open_id? instead (which checks for the presence of params[:openid_url] by default) [DHH]
+
+* Added OpenIdAuthentication::Result to make it easier to deal with default situations where you don't care to do something particular for each error state [DHH]
+
+* Stop relying on root_url being defined, we can just grab the current url instead [DHH]
Oops, something went wrong.

0 comments on commit f4252b2

Please sign in to comment.