authlogic 3.1.0 → 3.1.1

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.

data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source :rubygems
2
2
 
3
- gem 'activerecord', '>= 3.0.7'
3
+ gem 'activesupport', '>= 3.0.0'
4
+ gem 'activerecord', '>= 3.0.0'
4
5
 
5
6
  group :test do
6
7
  gem 'bcrypt-ruby'
data/Gemfile.lock CHANGED
@@ -1,32 +1,36 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.1.1)
5
- activesupport (= 3.1.1)
4
+ activemodel (3.2.5)
5
+ activesupport (= 3.2.5)
6
6
  builder (~> 3.0.0)
7
- i18n (~> 0.6)
8
- activerecord (3.1.1)
9
- activemodel (= 3.1.1)
10
- activesupport (= 3.1.1)
11
- arel (~> 2.2.1)
7
+ activerecord (3.2.5)
8
+ activemodel (= 3.2.5)
9
+ activesupport (= 3.2.5)
10
+ arel (~> 3.0.2)
12
11
  tzinfo (~> 0.3.29)
13
- activesupport (3.1.1)
12
+ activesupport (3.2.5)
13
+ i18n (~> 0.6)
14
14
  multi_json (~> 1.0)
15
15
  archive-tar-minitar (0.5.2)
16
- arel (2.2.1)
16
+ arel (3.0.2)
17
17
  bcrypt-ruby (3.0.1)
18
18
  builder (3.0.0)
19
- columnize (0.3.4)
19
+ columnize (0.3.6)
20
20
  git (1.2.5)
21
21
  i18n (0.6.0)
22
- jeweler (1.6.4)
22
+ jeweler (1.8.3)
23
23
  bundler (~> 1.0)
24
24
  git (>= 1.2.5)
25
25
  rake
26
+ rdoc
27
+ json (1.7.3)
26
28
  linecache19 (0.5.12)
27
29
  ruby_core_source (>= 0.1.4)
28
- multi_json (1.0.3)
29
- rake (0.9.2)
30
+ multi_json (1.3.6)
31
+ rake (0.9.2.2)
32
+ rdoc (3.12)
33
+ json (~> 1.4)
30
34
  ruby-debug-base19 (0.11.25)
31
35
  columnize (>= 0.3.1)
32
36
  linecache19 (>= 0.5.11)
@@ -37,14 +41,15 @@ GEM
37
41
  ruby-debug-base19 (>= 0.11.19)
38
42
  ruby_core_source (0.1.5)
39
43
  archive-tar-minitar (>= 0.5.2)
40
- sqlite3 (1.3.4)
41
- tzinfo (0.3.30)
44
+ sqlite3 (1.3.6)
45
+ tzinfo (0.3.33)
42
46
 
43
47
  PLATFORMS
44
48
  ruby
45
49
 
46
50
  DEPENDENCIES
47
- activerecord (>= 3.0.7)
51
+ activerecord (>= 3.0.0)
52
+ activesupport (>= 3.0.0)
48
53
  bcrypt-ruby
49
54
  jeweler
50
55
  rake
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Authlogic
2
2
 
3
- ** Please note the latest version is compatible with rails 3 only. Rails 2 should use version 2.X.X **
3
+ ** Please note the latest version is compatible with rails 3 only. Please see the rails2 branch for Rails 2 compatibility.
4
4
 
5
5
  Authlogic is a clean, simple, and unobtrusive ruby authentication solution.
6
6
 
@@ -174,8 +174,17 @@ What if your user sessions controller could look just like your other controller
174
174
 
175
175
  As you can see, this fits nicely into the RESTful development pattern. What about the view...
176
176
 
177
- <% form_for @user_session do |f| %>
178
- <%= f.error_messages %>
177
+ <%= form_for @user_session do |f| %>
178
+ <% if @user_session.errors.any? %>
179
+ <div id="error_explanation">
180
+ <h2><%= pluralize(@user_session.errors.count, "error") %> prohibited:</h2>
181
+ <ul>
182
+ <% @user_session.errors.full_messages.each do |msg| %>
183
+ <li><%= msg %></li>
184
+ <% end %>
185
+ </ul>
186
+ </div>
187
+ <% end %>
179
188
  <%= f.label :login %><br />
180
189
  <%= f.text_field :login %><br />
181
190
  <br />
@@ -204,19 +213,9 @@ Or how about persisting the session...
204
213
 
205
214
  == Install & Use
206
215
 
207
- Install the gem / plugin (recommended)
216
+ Install the gem
208
217
 
209
- Rails 3:
210
-
211
- $ sudo gem install authlogic
212
-
213
- Rails 2:
214
-
215
- $ sudo gem install authlogic --version=2.1.6
216
-
217
- Or install as a plugin:
218
-
219
- script/plugin install git://github.com/binarylogic/authlogic.git
218
+ $ gem 'authlogic'
220
219
 
221
220
  == Detailed Setup Tutorial
222
221
 
data/Rakefile CHANGED
@@ -12,7 +12,8 @@ begin
12
12
  gem.email = "bjohnson@binarylogic.com"
13
13
  gem.homepage = "http://github.com/binarylogic/authlogic"
14
14
  gem.authors = ["Ben Johnson of Binary Logic"]
15
- gem.add_bundler_dependencies
15
+ gem.add_dependency "activesupport", ">= 3.0.0"
16
+ gem.add_dependency "activerecord", ">= 3.0.0"
16
17
  end
17
18
  Jeweler::GemcutterTasks.new
18
19
  rescue LoadError
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 3
3
3
  :minor: 1
4
- :patch: 0
5
- :build: !!null
4
+ :patch: 1
5
+ :build:
data/authlogic.gemspec CHANGED
@@ -4,13 +4,13 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{authlogic}
8
- s.version = "3.1.0"
7
+ s.name = "authlogic"
8
+ s.version = "3.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Ben Johnson of Binary Logic}]
12
- s.date = %q{2011-10-19}
13
- s.email = %q{bjohnson@binarylogic.com}
11
+ s.authors = ["Ben Johnson of Binary Logic"]
12
+ s.date = "2012-06-01"
13
+ s.email = "bjohnson@binarylogic.com"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
16
16
  "README.rdoc"
@@ -145,24 +145,30 @@ Gem::Specification.new do |s|
145
145
  "test/session_test/validation_test.rb",
146
146
  "test/test_helper.rb"
147
147
  ]
148
- s.homepage = %q{http://github.com/binarylogic/authlogic}
149
- s.require_paths = [%q{lib}]
150
- s.rubygems_version = %q{1.8.6}
151
- s.summary = %q{A clean, simple, and unobtrusive ruby authentication solution.}
148
+ s.homepage = "http://github.com/binarylogic/authlogic"
149
+ s.require_paths = ["lib"]
150
+ s.rubygems_version = "1.8.24"
151
+ s.summary = "A clean, simple, and unobtrusive ruby authentication solution."
152
152
 
153
153
  if s.respond_to? :specification_version then
154
154
  s.specification_version = 3
155
155
 
156
156
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
157
- s.add_runtime_dependency(%q<activerecord>, [">= 3.0.7"])
158
- s.add_runtime_dependency(%q<activerecord>, [">= 3.0.7"])
157
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
158
+ s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
159
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
160
+ s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
159
161
  else
160
- s.add_dependency(%q<activerecord>, [">= 3.0.7"])
161
- s.add_dependency(%q<activerecord>, [">= 3.0.7"])
162
+ s.add_dependency(%q<activesupport>, [">= 3.0.0"])
163
+ s.add_dependency(%q<activerecord>, [">= 3.0.0"])
164
+ s.add_dependency(%q<activesupport>, [">= 3.0.0"])
165
+ s.add_dependency(%q<activerecord>, [">= 3.0.0"])
162
166
  end
163
167
  else
164
- s.add_dependency(%q<activerecord>, [">= 3.0.7"])
165
- s.add_dependency(%q<activerecord>, [">= 3.0.7"])
168
+ s.add_dependency(%q<activesupport>, [">= 3.0.0"])
169
+ s.add_dependency(%q<activerecord>, [">= 3.0.0"])
170
+ s.add_dependency(%q<activesupport>, [">= 3.0.0"])
171
+ s.add_dependency(%q<activerecord>, [">= 3.0.0"])
166
172
  end
167
173
  end
168
174
 
@@ -28,7 +28,7 @@ module Authlogic
28
28
  # See the various sub modules for the configuration they provide.
29
29
  def acts_as_authentic(unsupported_options = nil, &block)
30
30
  # Stop all configuration if the DB is not set up
31
- return if !db_setup?
31
+ raise StandardError.new("You must establish a database connection before using acts_as_authentic") if !db_setup?
32
32
 
33
33
  raise ArgumentError.new("You are using the old v1.X.X configuration method for Authlogic. Instead of " +
34
34
  "passing a hash of configuration options to acts_as_authentic, pass a block: acts_as_authentic { |c| c.my_option = my_value }") if !unsupported_options.nil?
@@ -65,7 +65,7 @@ module Authlogic
65
65
  # * <tt>Default:</tt> {:with => Authlogic::Regex.email, :message => lambda {I18n.t('error_messages.email_invalid', :default => "should look like an email address.")}}
66
66
  # * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
67
67
  def validates_format_of_email_field_options(value = nil)
68
- rw_config(:validates_format_of_email_field_options, value, {:with => Authlogic::Regex.email, :message => I18n.t('error_messages.email_invalid', :default => "should look like an email address.")})
68
+ rw_config(:validates_format_of_email_field_options, value, {:with => Authlogic::Regex.email, :message => lambda {I18n.t('error_messages.email_invalid', :default => "should look like an email address.")}})
69
69
  end
70
70
  alias_method :validates_format_of_email_field_options=, :validates_format_of_email_field_options
71
71
 
@@ -107,4 +107,4 @@ module Authlogic
107
107
  end
108
108
  end
109
109
  end
110
- end
110
+ end
@@ -31,8 +31,8 @@ module Authlogic
31
31
 
32
32
  klass.class_eval do
33
33
  include InstanceMethods
34
- scope :logged_in, where("last_request_at > ?", logged_in_timeout.seconds.ago)
35
- scope :logged_out, where("last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago)
34
+ scope :logged_in, lambda{ where("last_request_at > ?", logged_in_timeout.seconds.ago) }
35
+ scope :logged_out, lambda{ where("last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago) }
36
36
  end
37
37
  end
38
38
 
@@ -62,7 +62,7 @@ module Authlogic
62
62
  # * <tt>Default:</tt> {:with => Authlogic::Regex.login, :message => lambda {I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}}
63
63
  # * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
64
64
  def validates_format_of_login_field_options(value = nil)
65
- rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")})
65
+ rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => lambda {I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}})
66
66
  end
67
67
  alias_method :validates_format_of_login_field_options=, :validates_format_of_login_field_options
68
68
 
@@ -94,7 +94,7 @@ module Authlogic
94
94
  # manner that they handle that. If you are using the login field and set false for the :case_sensitive option in
95
95
  # validates_uniqueness_of_login_field_options this method will modify the query to look something like:
96
96
  #
97
- # where("LOWER(#{quoted_table_name}.#{login_field}) = ?", login.downcase).first
97
+ # where("#{quoted_table_name}.#{field} LIKE ?", login).first
98
98
  #
99
99
  # If you don't specify this it calls the good old find_by_* method:
100
100
  #
@@ -139,4 +139,4 @@ module Authlogic
139
139
  end
140
140
  end
141
141
  end
142
- end
142
+ end
@@ -58,7 +58,7 @@ module Authlogic
58
58
  alias_method :ignore_blank_passwords=, :ignore_blank_passwords
59
59
 
60
60
  # When calling valid_password?("some pass") do you want to check that password against what's in that object or whats in
61
- # the datbase. Take this example:
61
+ # the database. Take this example:
62
62
  #
63
63
  # u = User.first
64
64
  # u.password = "new pass"
@@ -1,7 +1,7 @@
1
1
  module Authlogic
2
2
  module ActsAsAuthentic
3
3
  # Maintains the persistence token, the token responsible for persisting sessions. This token
4
- # gets stores in the session and the cookie.
4
+ # gets stored in the session and the cookie.
5
5
  module PersistenceToken
6
6
  def self.included(klass)
7
7
  klass.class_eval do
@@ -1,3 +1,5 @@
1
+ require 'action_controller'
2
+
1
3
  module Authlogic
2
4
  module ControllerAdapters
3
5
  # Adapts authlogic to work with rails. The point is to close the gap between what authlogic expects and what the rails controller object
@@ -58,4 +58,4 @@ module Authlogic
58
58
  end
59
59
  end
60
60
 
61
- Sinatra::Request.send(:include, Authlogic::ControllerAdapters::SinatraAdapter::Adapter::Implementation)
61
+ Sinatra::Base.send(:include, Authlogic::ControllerAdapters::SinatraAdapter::Adapter::Implementation)
@@ -27,7 +27,7 @@ module Authlogic
27
27
  class << self
28
28
  attr_accessor :join_token
29
29
 
30
- # The number of times to loop through the encryption. This is ten because that is what restful_authentication defaults to.
30
+ # The number of times to loop through the encryption. This is twenty because that is what restful_authentication defaults to.
31
31
  def stretches
32
32
  @stretches ||= 20
33
33
  end
@@ -9,17 +9,18 @@ module Authlogic
9
9
  # by reading this website: http://www.regular-expressions.info/email.html, which is an excellent resource
10
10
  # for regular expressions.
11
11
  def self.email
12
- return @email_regex if @email_regex
13
- email_name_regex = '[A-Z0-9_\.%\+\-\']+'
14
- domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
15
- domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)'
16
- @email_regex = /^#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}$/i
12
+ @email_regex ||= begin
13
+ email_name_regex = '[A-Z0-9_\.%\+\-\']+'
14
+ domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
15
+ domain_tld_regex = '(?:[A-Z]{2,4}|museum|travel)'
16
+ /\A#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}\z/i
17
+ end
17
18
  end
18
19
 
19
20
  # A simple regular expression that only allows for letters, numbers, spaces, and .-_@. Just a standard login / username
20
21
  # regular expression.
21
22
  def self.login
22
- /\A\w[\w\.+\-_@ ]+$/
23
+ /\A\w[\w\.+\-_@ ]+\z/
23
24
  end
24
25
  end
25
26
  end
@@ -19,7 +19,7 @@ module Authlogic
19
19
  def rw_config(key, value, default_value = nil, read_value = nil)
20
20
  if value == read_value
21
21
  return acts_as_authentic_config[key] if acts_as_authentic_config.include?(key)
22
- rw_config(key, default_value)
22
+ rw_config(key, default_value) unless default_value.nil?
23
23
  else
24
24
  config = acts_as_authentic_config.clone
25
25
  config[key] = value
@@ -74,4 +74,4 @@ module Authlogic
74
74
  end
75
75
  end
76
76
  end
77
- end
77
+ end
@@ -46,7 +46,7 @@ module Authlogic
46
46
 
47
47
  module InstanceMethods
48
48
  # Let's you know if the session is being persisted or not, meaning the user does not have to explicitly log in
49
- # in order to be logged in. If the session has no associated record, it will try to find a record and persis
49
+ # in order to be logged in. If the session has no associated record, it will try to find a record and persist
50
50
  # the session. This is the method that the class level method find uses to ultimately persist the session.
51
51
  def persisting?
52
52
  return true if !record.nil?
@@ -85,6 +85,10 @@ module ActsAsAuthenticTest
85
85
  u.email = "dakota.d'ux@gmail.com"
86
86
  u.valid?
87
87
  assert u.errors[:email].size == 0
88
+
89
+ u.email = "<script>alert(123);</script>\nnobody@example.com"
90
+ assert !u.valid?
91
+ assert u.errors[:email].size > 0
88
92
  end
89
93
 
90
94
  def test_validates_uniqueness_of_email_field
@@ -2,6 +2,8 @@ require 'test_helper'
2
2
 
3
3
  module ActsAsAuthenticTest
4
4
  class LoggedInStatusTest < ActiveSupport::TestCase
5
+ ERROR_MSG = 'Multiple calls to %s should result in different relations'
6
+
5
7
  def test_logged_in_timeout_config
6
8
  assert_equal 10.minutes.to_i, User.logged_in_timeout
7
9
  assert_equal 10.minutes.to_i, Employee.logged_in_timeout
@@ -13,12 +15,24 @@ module ActsAsAuthenticTest
13
15
  end
14
16
 
15
17
  def test_named_scope_logged_in
18
+ # Testing that the scope returned differs, because the time it was called should be
19
+ # slightly different. This is an attempt to make sure the scope is lambda wrapped
20
+ # so that it is re-evaluated every time its called. My biggest concern is that the
21
+ # test happens so fast that the test fails... I just don't know a better way to test it!
22
+ assert User.logged_in.where_values != User.logged_in.where_values, ERROR_MSG % '#logged_in'
23
+
16
24
  assert_equal 0, User.logged_in.count
17
25
  User.first.update_attribute(:last_request_at, Time.now)
18
26
  assert_equal 1, User.logged_in.count
19
27
  end
20
28
 
21
29
  def test_named_scope_logged_out
30
+ # Testing that the scope returned differs, because the time it was called should be
31
+ # slightly different. This is an attempt to make sure the scope is lambda wrapped
32
+ # so that it is re-evaluated every time its called. My biggest concern is that the
33
+ # test happens so fast that the test fails... I just don't know a better way to test it!
34
+ assert User.logged_in.where_values != User.logged_out.where_values, ERROR_MSG % '#logged_out'
35
+
22
36
  assert_equal 2, User.logged_out.count
23
37
  User.first.update_attribute(:last_request_at, Time.now)
24
38
  assert_equal 1, User.logged_out.count
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,30 +9,72 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-19 00:00:00.000000000Z
12
+ date: 2012-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: activerecord
16
- requirement: &70092428968260 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 3.0.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 3.0.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: activesupport
48
+ requirement: !ruby/object:Gem::Requirement
17
49
  none: false
18
50
  requirements:
19
51
  - - ! '>='
20
52
  - !ruby/object:Gem::Version
21
- version: 3.0.7
53
+ version: 3.0.0
22
54
  type: :runtime
23
55
  prerelease: false
24
- version_requirements: *70092428968260
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
25
62
  - !ruby/object:Gem::Dependency
26
63
  name: activerecord
27
- requirement: &70092428967600 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
28
65
  none: false
29
66
  requirements:
30
67
  - - ! '>='
31
68
  - !ruby/object:Gem::Version
32
- version: 3.0.7
69
+ version: 3.0.0
33
70
  type: :runtime
34
71
  prerelease: false
35
- version_requirements: *70092428967600
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 3.0.0
36
78
  description:
37
79
  email: bjohnson@binarylogic.com
38
80
  executables: []
@@ -183,7 +225,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
225
  version: '0'
184
226
  segments:
185
227
  - 0
186
- hash: 3222304498311125982
228
+ hash: 1092096732576566616
187
229
  required_rubygems_version: !ruby/object:Gem::Requirement
188
230
  none: false
189
231
  requirements:
@@ -192,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
234
  version: '0'
193
235
  requirements: []
194
236
  rubyforge_project:
195
- rubygems_version: 1.8.6
237
+ rubygems_version: 1.8.24
196
238
  signing_key:
197
239
  specification_version: 3
198
240
  summary: A clean, simple, and unobtrusive ruby authentication solution.