authlogic 0.10.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of authlogic might be problematic. Click here for more details.

Files changed (102) hide show
  1. data/CHANGELOG.rdoc +47 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Manifest +100 -0
  4. data/README.rdoc +292 -0
  5. data/Rakefile +15 -0
  6. data/authlogic.gemspec +38 -0
  7. data/init.rb +1 -0
  8. data/lib/authlogic.rb +25 -0
  9. data/lib/authlogic/active_record/acts_as_authentic.rb +265 -0
  10. data/lib/authlogic/active_record/authenticates_many.rb +19 -0
  11. data/lib/authlogic/active_record/scoped_session.rb +28 -0
  12. data/lib/authlogic/controller_adapters/abstract_adapter.rb +25 -0
  13. data/lib/authlogic/controller_adapters/rails_adapter.rb +39 -0
  14. data/lib/authlogic/session/active_record_trickery.rb +26 -0
  15. data/lib/authlogic/session/base.rb +510 -0
  16. data/lib/authlogic/session/callbacks.rb +56 -0
  17. data/lib/authlogic/session/config.rb +237 -0
  18. data/lib/authlogic/session/errors.rb +18 -0
  19. data/lib/authlogic/sha512_crypto_provider.rb +18 -0
  20. data/lib/authlogic/version.rb +56 -0
  21. data/test_app/README +256 -0
  22. data/test_app/Rakefile +10 -0
  23. data/test_app/app/controllers/application.rb +72 -0
  24. data/test_app/app/controllers/companies_controller.rb +2 -0
  25. data/test_app/app/controllers/user_sessions_controller.rb +25 -0
  26. data/test_app/app/controllers/users_controller.rb +61 -0
  27. data/test_app/app/helpers/application_helper.rb +3 -0
  28. data/test_app/app/helpers/companies_helper.rb +2 -0
  29. data/test_app/app/helpers/user_sessions_helper.rb +2 -0
  30. data/test_app/app/helpers/users_helper.rb +2 -0
  31. data/test_app/app/models/company.rb +4 -0
  32. data/test_app/app/models/project.rb +3 -0
  33. data/test_app/app/models/user.rb +5 -0
  34. data/test_app/app/models/user_session.rb +3 -0
  35. data/test_app/app/views/layouts/application.html.erb +27 -0
  36. data/test_app/app/views/user_sessions/new.html.erb +15 -0
  37. data/test_app/app/views/users/_form.erb +15 -0
  38. data/test_app/app/views/users/edit.html.erb +8 -0
  39. data/test_app/app/views/users/new.html.erb +8 -0
  40. data/test_app/app/views/users/show.html.erb +29 -0
  41. data/test_app/config/boot.rb +109 -0
  42. data/test_app/config/database.yml +19 -0
  43. data/test_app/config/environment.rb +69 -0
  44. data/test_app/config/environments/development.rb +17 -0
  45. data/test_app/config/environments/production.rb +22 -0
  46. data/test_app/config/environments/test.rb +22 -0
  47. data/test_app/config/initializers/inflections.rb +10 -0
  48. data/test_app/config/initializers/mime_types.rb +5 -0
  49. data/test_app/config/initializers/new_rails_defaults.rb +17 -0
  50. data/test_app/config/routes.rb +11 -0
  51. data/test_app/db/development.sqlite3 +0 -0
  52. data/test_app/db/migrate/20081023040052_create_users.rb +20 -0
  53. data/test_app/db/migrate/20081103003828_create_companies.rb +14 -0
  54. data/test_app/db/migrate/20081103003834_create_projects.rb +18 -0
  55. data/test_app/db/schema.rb +46 -0
  56. data/test_app/db/test.sqlite3 +0 -0
  57. data/test_app/doc/README_FOR_APP +2 -0
  58. data/test_app/public/404.html +30 -0
  59. data/test_app/public/422.html +30 -0
  60. data/test_app/public/500.html +30 -0
  61. data/test_app/public/dispatch.cgi +10 -0
  62. data/test_app/public/dispatch.fcgi +24 -0
  63. data/test_app/public/dispatch.rb +10 -0
  64. data/test_app/public/favicon.ico +0 -0
  65. data/test_app/public/images/rails.png +0 -0
  66. data/test_app/public/javascripts/application.js +2 -0
  67. data/test_app/public/javascripts/controls.js +963 -0
  68. data/test_app/public/javascripts/dragdrop.js +972 -0
  69. data/test_app/public/javascripts/effects.js +1120 -0
  70. data/test_app/public/javascripts/prototype.js +4225 -0
  71. data/test_app/public/robots.txt +5 -0
  72. data/test_app/public/stylesheets/scaffold.css +62 -0
  73. data/test_app/script/about +4 -0
  74. data/test_app/script/console +3 -0
  75. data/test_app/script/dbconsole +3 -0
  76. data/test_app/script/destroy +3 -0
  77. data/test_app/script/generate +3 -0
  78. data/test_app/script/performance/benchmarker +3 -0
  79. data/test_app/script/performance/profiler +3 -0
  80. data/test_app/script/performance/request +3 -0
  81. data/test_app/script/plugin +3 -0
  82. data/test_app/script/process/inspector +3 -0
  83. data/test_app/script/process/reaper +3 -0
  84. data/test_app/script/process/spawner +3 -0
  85. data/test_app/script/runner +3 -0
  86. data/test_app/script/server +3 -0
  87. data/test_app/test/fixtures/companies.yml +7 -0
  88. data/test_app/test/fixtures/projects.yml +4 -0
  89. data/test_app/test/fixtures/users.yml +21 -0
  90. data/test_app/test/functional/companies_controller_test.rb +8 -0
  91. data/test_app/test/functional/user_sessions_controller_test.rb +36 -0
  92. data/test_app/test/functional/users_controller_test.rb +8 -0
  93. data/test_app/test/integration/company_user_session_stories_test.rb +46 -0
  94. data/test_app/test/integration/user_sesion_stories_test.rb +105 -0
  95. data/test_app/test/integration/user_session_config_test.rb +24 -0
  96. data/test_app/test/integration/user_session_test.rb +161 -0
  97. data/test_app/test/test_helper.rb +81 -0
  98. data/test_app/test/unit/account_test.rb +8 -0
  99. data/test_app/test/unit/company_test.rb +8 -0
  100. data/test_app/test/unit/project_test.rb +8 -0
  101. data/test_app/test/unit/user_test.rb +80 -0
  102. metadata +201 -0
@@ -0,0 +1,81 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
+ require 'test_help'
4
+
5
+ class Test::Unit::TestCase
6
+ self.use_transactional_fixtures = true
7
+ self.use_instantiated_fixtures = false
8
+ fixtures :all
9
+ end
10
+
11
+ class ActionController::IntegrationTest
12
+ attr_accessor :scope
13
+
14
+ def setup
15
+ get new_user_session_url # to active authlogic
16
+ end
17
+
18
+ def teardown
19
+ Authlogic::Session::Base.controller = nil
20
+ end
21
+
22
+ private
23
+ def assert_successful_login(login, password)
24
+ post scoped_url("user_session_url"), :user_session => {:login => login, :password => password}
25
+ assert_redirected_to scoped_url("account_url")
26
+ follow_redirect!
27
+ assert_template "users/show"
28
+ end
29
+
30
+ def assert_unsuccessful_login(login = nil, password = nil)
31
+ params = (login || password) ? {:user_session => {:login => login, :password => password}} : nil
32
+ post scoped_url("user_session_url"), params
33
+ assert_template "user_sessions/new"
34
+ end
35
+
36
+ def assert_successful_logout(alt_redirect = nil)
37
+ redirecting_to = alt_redirect || scoped_url("new_user_session_url")
38
+ delete scoped_url("user_session_url")
39
+ assert_redirected_to redirecting_to # because I tried to access registration above, and it stored it
40
+ follow_redirect!
41
+ assert flash.key?(:notice)
42
+ assert_equal nil, session[scoped_key]
43
+ assert_equal "", cookies[scoped_key]
44
+ assert_template redirecting_to.gsub("http://www.example.com/", "").gsub("user_session", "user_sessions").gsub("account", "users").gsub(/^companies\/[1-9]*\//, "")
45
+ end
46
+
47
+ def assert_account_access(user = nil)
48
+ user ||= users(:ben).reload
49
+ # Perform multiple requests to make sure the session is persisting properly, just being anal here
50
+ 3.times do
51
+ get scoped_url("account_url")
52
+ assert_equal user.remember_token, session[scoped_key]
53
+ assert_equal user.remember_token, cookies[scoped_key]
54
+ assert_response :success
55
+ assert_template "users/show"
56
+ end
57
+ end
58
+
59
+ def assert_no_account_access(alt_redirect = nil)
60
+ get scoped_url("account_url")
61
+ assert_redirected_to alt_redirect || scoped_url("new_user_session_url")
62
+ end
63
+
64
+ def scoped_url(unscoped_url, *args)
65
+ case scope
66
+ when Company
67
+ regex = /^(new|edit)_/
68
+ prefix = unscoped_url =~ regex ? "#{$1}_" : ""
69
+ send("#{prefix}company_#{unscoped_url.gsub(regex, "")}", scope.id, *args)
70
+ else
71
+ send(unscoped_url, *args)
72
+ end
73
+ end
74
+
75
+ def scoped_key
76
+ parts = []
77
+ parts << "#{scope.class.model_name.underscore}_#{scope.id}" if scope
78
+ parts << "user_credentials"
79
+ parts.join("_")
80
+ end
81
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class AccountTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class CompanyTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class ProjectTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,80 @@
1
+ require 'test_helper'
2
+
3
+ class UserTest < ActiveSupport::TestCase
4
+ def test_validations
5
+ user = User.new
6
+ assert !user.valid?
7
+ assert user.errors.on(:login)
8
+ user.login = "^fds#%"
9
+ assert !user.valid?
10
+ assert user.errors.on(:login)
11
+ user.login = "bjohnson"
12
+ assert !user.valid?
13
+ assert user.errors.on(:login)
14
+ user.login = "unique"
15
+ assert !user.valid?
16
+ assert user.errors.on(:password)
17
+ user.password = "awesome"
18
+ assert !user.valid?
19
+ assert user.errors.on(:confirm_password)
20
+ user.confirm_password = "awesome"
21
+ assert user.valid?
22
+ end
23
+
24
+ def test_unique_token
25
+ tokens = []
26
+ 100.times { tokens << User.unique_token }
27
+ assert_equal 100, tokens.uniq.size
28
+ end
29
+
30
+ def test_crypto_provider
31
+ assert_equal Authlogic::Sha512CryptoProvider, User.crypto_provider
32
+ end
33
+
34
+ def test_forget_all
35
+ bens_token = users(:ben).remember_token
36
+ zacks_token = users(:zack).remember_token
37
+ User.forget_all!
38
+ assert_not_equal bens_token, users(:ben).reload.remember_token
39
+ assert_not_equal zacks_token, users(:zack).reload.remember_token
40
+ end
41
+
42
+ def test_logged_in
43
+ ben = users(:ben)
44
+ assert !ben.logged_in?
45
+ ben.update_attribute(:last_request_at, Time.now)
46
+ assert ben.logged_in?
47
+ end
48
+
49
+ def test_password
50
+ user = User.new
51
+ user.password = "test"
52
+ assert user.password_salt
53
+ assert_equal User.crypto_provider.encrypt("test" + user.password_salt), user.crypted_password
54
+ assert user.remember_token
55
+ end
56
+
57
+ def test_valid_password
58
+ ben = users(:ben)
59
+ assert ben.valid_password?("benrocks")
60
+ assert ben.valid_password?(User.crypto_provider.encrypt("benrocks" + ben.password_salt))
61
+ end
62
+
63
+ def test_forget
64
+ ben = users(:ben)
65
+ token = ben.remember_token
66
+ ben.forget!
67
+ ben.reload
68
+ assert_not_equal token, ben.remember_token
69
+ end
70
+
71
+ def test_randomize_password
72
+ ben = users(:ben)
73
+ crypted_password = ben.crypted_password
74
+ password_salt = ben.password_salt
75
+ ben.randomize_password!
76
+ ben.reload
77
+ assert_not_equal crypted_password, ben.crypted_password
78
+ assert_not_equal password_salt, ben.password_salt
79
+ end
80
+ end
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: authlogic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.4
5
+ platform: ruby
6
+ authors:
7
+ - Ben Johnson of Binary Logic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-03 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: activerecord
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: echoe
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: Rails authentication done right
46
+ email: bjohnson@binarylogic.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - CHANGELOG.rdoc
53
+ - lib/authlogic/active_record/acts_as_authentic.rb
54
+ - lib/authlogic/active_record/authenticates_many.rb
55
+ - lib/authlogic/active_record/scoped_session.rb
56
+ - lib/authlogic/controller_adapters/abstract_adapter.rb
57
+ - lib/authlogic/controller_adapters/rails_adapter.rb
58
+ - lib/authlogic/session/active_record_trickery.rb
59
+ - lib/authlogic/session/base.rb
60
+ - lib/authlogic/session/callbacks.rb
61
+ - lib/authlogic/session/config.rb
62
+ - lib/authlogic/session/errors.rb
63
+ - lib/authlogic/sha512_crypto_provider.rb
64
+ - lib/authlogic/version.rb
65
+ - lib/authlogic.rb
66
+ - README.rdoc
67
+ files:
68
+ - CHANGELOG.rdoc
69
+ - init.rb
70
+ - lib/authlogic/active_record/acts_as_authentic.rb
71
+ - lib/authlogic/active_record/authenticates_many.rb
72
+ - lib/authlogic/active_record/scoped_session.rb
73
+ - lib/authlogic/controller_adapters/abstract_adapter.rb
74
+ - lib/authlogic/controller_adapters/rails_adapter.rb
75
+ - lib/authlogic/session/active_record_trickery.rb
76
+ - lib/authlogic/session/base.rb
77
+ - lib/authlogic/session/callbacks.rb
78
+ - lib/authlogic/session/config.rb
79
+ - lib/authlogic/session/errors.rb
80
+ - lib/authlogic/sha512_crypto_provider.rb
81
+ - lib/authlogic/version.rb
82
+ - lib/authlogic.rb
83
+ - Manifest
84
+ - MIT-LICENSE
85
+ - Rakefile
86
+ - README.rdoc
87
+ - test_app/app/controllers/application.rb
88
+ - test_app/app/controllers/companies_controller.rb
89
+ - test_app/app/controllers/user_sessions_controller.rb
90
+ - test_app/app/controllers/users_controller.rb
91
+ - test_app/app/helpers/application_helper.rb
92
+ - test_app/app/helpers/companies_helper.rb
93
+ - test_app/app/helpers/user_sessions_helper.rb
94
+ - test_app/app/helpers/users_helper.rb
95
+ - test_app/app/models/company.rb
96
+ - test_app/app/models/project.rb
97
+ - test_app/app/models/user.rb
98
+ - test_app/app/models/user_session.rb
99
+ - test_app/app/views/layouts/application.html.erb
100
+ - test_app/app/views/user_sessions/new.html.erb
101
+ - test_app/app/views/users/_form.erb
102
+ - test_app/app/views/users/edit.html.erb
103
+ - test_app/app/views/users/new.html.erb
104
+ - test_app/app/views/users/show.html.erb
105
+ - test_app/config/boot.rb
106
+ - test_app/config/database.yml
107
+ - test_app/config/environment.rb
108
+ - test_app/config/environments/development.rb
109
+ - test_app/config/environments/production.rb
110
+ - test_app/config/environments/test.rb
111
+ - test_app/config/initializers/inflections.rb
112
+ - test_app/config/initializers/mime_types.rb
113
+ - test_app/config/initializers/new_rails_defaults.rb
114
+ - test_app/config/routes.rb
115
+ - test_app/db/development.sqlite3
116
+ - test_app/db/migrate/20081023040052_create_users.rb
117
+ - test_app/db/migrate/20081103003828_create_companies.rb
118
+ - test_app/db/migrate/20081103003834_create_projects.rb
119
+ - test_app/db/schema.rb
120
+ - test_app/db/test.sqlite3
121
+ - test_app/doc/README_FOR_APP
122
+ - test_app/public/404.html
123
+ - test_app/public/422.html
124
+ - test_app/public/500.html
125
+ - test_app/public/dispatch.cgi
126
+ - test_app/public/dispatch.fcgi
127
+ - test_app/public/dispatch.rb
128
+ - test_app/public/favicon.ico
129
+ - test_app/public/images/rails.png
130
+ - test_app/public/javascripts/application.js
131
+ - test_app/public/javascripts/controls.js
132
+ - test_app/public/javascripts/dragdrop.js
133
+ - test_app/public/javascripts/effects.js
134
+ - test_app/public/javascripts/prototype.js
135
+ - test_app/public/robots.txt
136
+ - test_app/public/stylesheets/scaffold.css
137
+ - test_app/Rakefile
138
+ - test_app/README
139
+ - test_app/script/about
140
+ - test_app/script/console
141
+ - test_app/script/dbconsole
142
+ - test_app/script/destroy
143
+ - test_app/script/generate
144
+ - test_app/script/performance/benchmarker
145
+ - test_app/script/performance/profiler
146
+ - test_app/script/performance/request
147
+ - test_app/script/plugin
148
+ - test_app/script/process/inspector
149
+ - test_app/script/process/reaper
150
+ - test_app/script/process/spawner
151
+ - test_app/script/runner
152
+ - test_app/script/server
153
+ - test_app/test/fixtures/companies.yml
154
+ - test_app/test/fixtures/projects.yml
155
+ - test_app/test/fixtures/users.yml
156
+ - test_app/test/functional/companies_controller_test.rb
157
+ - test_app/test/functional/user_sessions_controller_test.rb
158
+ - test_app/test/functional/users_controller_test.rb
159
+ - test_app/test/integration/company_user_session_stories_test.rb
160
+ - test_app/test/integration/user_sesion_stories_test.rb
161
+ - test_app/test/integration/user_session_config_test.rb
162
+ - test_app/test/integration/user_session_test.rb
163
+ - test_app/test/test_helper.rb
164
+ - test_app/test/unit/account_test.rb
165
+ - test_app/test/unit/company_test.rb
166
+ - test_app/test/unit/project_test.rb
167
+ - test_app/test/unit/user_test.rb
168
+ - authlogic.gemspec
169
+ has_rdoc: true
170
+ homepage: http://github.com/binarylogic/authlogic
171
+ post_install_message:
172
+ rdoc_options:
173
+ - --line-numbers
174
+ - --inline-source
175
+ - --title
176
+ - Authlogic
177
+ - --main
178
+ - README.rdoc
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: "0"
186
+ version:
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: "1.2"
192
+ version:
193
+ requirements: []
194
+
195
+ rubyforge_project: authlogic
196
+ rubygems_version: 1.2.0
197
+ signing_key:
198
+ specification_version: 2
199
+ summary: Rails authentication done right
200
+ test_files: []
201
+