authlogic 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -1
  3. data/.travis.yml +27 -0
  4. data/CONTRIBUTING.md +10 -0
  5. data/Gemfile.lock +46 -28
  6. data/History +10 -0
  7. data/README.rdoc +2 -0
  8. data/Rakefile +0 -13
  9. data/authlogic.gemspec +8 -7
  10. data/lib/authlogic/acts_as_authentic/email.rb +1 -1
  11. data/lib/authlogic/acts_as_authentic/login.rb +12 -13
  12. data/lib/authlogic/acts_as_authentic/password.rb +47 -47
  13. data/lib/authlogic/acts_as_authentic/perishable_token.rb +1 -1
  14. data/lib/authlogic/acts_as_authentic/persistence_token.rb +1 -1
  15. data/lib/authlogic/authenticates_many/base.rb +1 -1
  16. data/lib/authlogic/controller_adapters/sinatra_adapter.rb +1 -1
  17. data/lib/authlogic/crypto_providers/bcrypt.rb +19 -18
  18. data/lib/authlogic/crypto_providers/scrypt.rb +7 -6
  19. data/lib/authlogic/regex.rb +3 -2
  20. data/lib/authlogic/session/activation.rb +5 -3
  21. data/lib/authlogic/session/active_record_trickery.rb +23 -1
  22. data/lib/authlogic/session/callbacks.rb +8 -3
  23. data/lib/authlogic/session/cookies.rb +52 -17
  24. data/lib/authlogic/session/foundation.rb +1 -9
  25. data/lib/authlogic/session/magic_columns.rb +3 -3
  26. data/lib/authlogic/session/scopes.rb +11 -4
  27. data/lib/authlogic/session/session.rb +8 -8
  28. data/lib/authlogic/test_case.rb +7 -5
  29. data/lib/authlogic/test_case/mock_cookie_jar.rb +25 -0
  30. data/lib/authlogic/test_case/mock_request.rb +2 -2
  31. data/test/acts_as_authentic_test/logged_in_status_test.rb +3 -3
  32. data/test/acts_as_authentic_test/password_test.rb +16 -7
  33. data/test/crypto_provider_test/bcrypt_test.rb +1 -9
  34. data/test/fixtures/users.yml +13 -1
  35. data/test/gemfiles/Gemfile.rails-3.2.x +5 -0
  36. data/test/gemfiles/Gemfile.rails-4.0.x +5 -0
  37. data/test/gemfiles/Gemfile.rails-4.1.x +5 -0
  38. data/test/session_test/active_record_trickery_test.rb +29 -0
  39. data/test/session_test/cookies_test.rb +26 -1
  40. data/test/session_test/session_test.rb +7 -7
  41. data/test/test_helper.rb +3 -1
  42. metadata +59 -55
  43. data/lib/authlogic/controller_adapters/rack_adapter.rb +0 -63
@@ -1,63 +0,0 @@
1
- module Authlogic
2
- module ControllerAdapters
3
- # Adapter for authlogic to make it function as a Rack middleware.
4
- # First you'll have write your own Rack adapter where you have to set your cookie domain.
5
- #
6
- # class YourRackAdapter < Authlogic::ControllerAdapters::RackAdapter
7
- # def cookie_domain
8
- # 'your_cookie_domain_here.com'
9
- # end
10
- # end
11
- #
12
- # Next you need to set up a rack middleware like this:
13
- #
14
- # class AuthlogicMiddleware
15
- # def initialize(app)
16
- # @app = app
17
- # end
18
- #
19
- # def call(env)
20
- # YourRackAdapter.new(env)
21
- # @app.call(env)
22
- # end
23
- # end
24
- #
25
- # And that is all! Now just load this middleware into rack:
26
- #
27
- # use AuthlogicMiddleware
28
- #
29
- # Authlogic will expect a User and a UserSession object to be present:
30
- #
31
- # class UserSession < Authlogic::Session::Base
32
- # # Authlogic options go here
33
- # end
34
- #
35
- # class User < ActiveRecord::Base
36
- # acts_as_authentic
37
- # end
38
- #
39
- class RackAdapter < AbstractAdapter
40
-
41
- def initialize(env)
42
- # We use the Rack::Request object as the controller object.
43
- # For this to work, we have to add some glue.
44
- request = Rack::Request.new(env)
45
-
46
- request.instance_eval do
47
- def request; self; end
48
- def remote_ip; self.ip; end
49
- end
50
-
51
- super(request)
52
- Authlogic::Session::Base.controller = self
53
- end
54
-
55
- # Rack Requests stores cookies with not just the value, but also with flags and expire information in the hash.
56
- # Authlogic does not like this, so we drop everything except the cookie value
57
- def cookies
58
- controller.cookies.map{|key, value_hash| {key => value_hash[:value]} }.inject(:merge) || {}
59
- end
60
- end
61
- end
62
-
63
- end