sorcery 0.8.6 → 0.9.0

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

Potentially problematic release.


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

Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.travis.yml +75 -14
  4. data/CHANGELOG.md +23 -1
  5. data/Gemfile +1 -0
  6. data/README.md +137 -86
  7. data/gemfiles/active_record-rails40.gemfile +7 -0
  8. data/gemfiles/active_record-rails41.gemfile +3 -2
  9. data/gemfiles/mongo_mapper-rails40.gemfile +9 -0
  10. data/gemfiles/mongo_mapper-rails41.gemfile +2 -1
  11. data/gemfiles/mongoid-rails40.gemfile +9 -0
  12. data/gemfiles/mongoid-rails41.gemfile +3 -5
  13. data/gemfiles/mongoid3-rails32.gemfile +9 -0
  14. data/lib/generators/sorcery/USAGE +1 -1
  15. data/lib/generators/sorcery/install_generator.rb +19 -5
  16. data/lib/generators/sorcery/templates/initializer.rb +34 -9
  17. data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +3 -1
  18. data/lib/generators/sorcery/templates/migration/core.rb +2 -2
  19. data/lib/generators/sorcery/templates/migration/external.rb +3 -1
  20. data/lib/sorcery.rb +75 -43
  21. data/lib/sorcery/adapters/active_record_adapter.rb +120 -0
  22. data/lib/sorcery/adapters/base_adapter.rb +30 -0
  23. data/lib/sorcery/adapters/data_mapper_adapter.rb +176 -0
  24. data/lib/sorcery/adapters/mongo_mapper_adapter.rb +110 -0
  25. data/lib/sorcery/adapters/mongoid_adapter.rb +97 -0
  26. data/lib/sorcery/controller.rb +5 -64
  27. data/lib/sorcery/controller/config.rb +65 -0
  28. data/lib/sorcery/controller/submodules/activity_logging.rb +16 -21
  29. data/lib/sorcery/controller/submodules/brute_force_protection.rb +6 -6
  30. data/lib/sorcery/controller/submodules/external.rb +8 -28
  31. data/lib/sorcery/controller/submodules/remember_me.rb +4 -4
  32. data/lib/sorcery/controller/submodules/session_timeout.rb +10 -6
  33. data/lib/sorcery/model.rb +43 -175
  34. data/lib/sorcery/model/config.rb +96 -0
  35. data/lib/sorcery/model/submodules/activity_logging.rb +29 -36
  36. data/lib/sorcery/model/submodules/brute_force_protection.rb +21 -37
  37. data/lib/sorcery/model/submodules/external.rb +53 -9
  38. data/lib/sorcery/model/submodules/remember_me.rb +12 -31
  39. data/lib/sorcery/model/submodules/reset_password.rb +21 -39
  40. data/lib/sorcery/model/submodules/user_activation.rb +21 -63
  41. data/lib/sorcery/model/temporary_token.rb +4 -4
  42. data/lib/sorcery/providers/base.rb +11 -0
  43. data/lib/sorcery/providers/facebook.rb +1 -1
  44. data/lib/sorcery/providers/github.rb +1 -1
  45. data/lib/sorcery/providers/google.rb +1 -1
  46. data/lib/sorcery/providers/heroku.rb +57 -0
  47. data/lib/sorcery/providers/jira.rb +77 -0
  48. data/lib/sorcery/providers/linkedin.rb +1 -1
  49. data/lib/sorcery/providers/liveid.rb +1 -1
  50. data/lib/sorcery/providers/salesforce.rb +50 -0
  51. data/lib/sorcery/providers/twitter.rb +1 -1
  52. data/lib/sorcery/providers/vk.rb +6 -4
  53. data/lib/sorcery/providers/xing.rb +1 -1
  54. data/lib/sorcery/test_helpers/internal.rb +7 -3
  55. data/lib/sorcery/test_helpers/rails/controller.rb +5 -1
  56. data/lib/sorcery/version.rb +3 -0
  57. data/sorcery.gemspec +6 -2
  58. data/spec/active_record/user_activity_logging_spec.rb +9 -0
  59. data/spec/controllers/controller_activity_logging_spec.rb +124 -0
  60. data/spec/controllers/controller_brute_force_protection_spec.rb +43 -0
  61. data/spec/{active_record → controllers}/controller_http_basic_auth_spec.rb +14 -11
  62. data/spec/{active_record → controllers}/controller_oauth2_spec.rb +128 -56
  63. data/spec/{active_record → controllers}/controller_oauth_spec.rb +94 -70
  64. data/spec/{active_record → controllers}/controller_remember_me_spec.rb +32 -12
  65. data/spec/{active_record → controllers}/controller_session_timeout_spec.rb +15 -5
  66. data/spec/{shared_examples/controller_shared_examples.rb → controllers/controller_spec.rb} +34 -19
  67. data/spec/{datamapper → data_mapper}/user_activation_spec.rb +1 -1
  68. data/spec/data_mapper/user_activity_logging_spec.rb +14 -0
  69. data/spec/{datamapper → data_mapper}/user_brute_force_protection_spec.rb +1 -1
  70. data/spec/{datamapper → data_mapper}/user_oauth_spec.rb +1 -1
  71. data/spec/{datamapper → data_mapper}/user_remember_me_spec.rb +1 -1
  72. data/spec/{datamapper → data_mapper}/user_reset_password_spec.rb +1 -1
  73. data/spec/{datamapper → data_mapper}/user_spec.rb +1 -1
  74. data/spec/mongoid/user_spec.rb +13 -0
  75. data/spec/orm/active_record.rb +12 -0
  76. data/spec/orm/{datamapper.rb → data_mapper.rb} +16 -2
  77. data/spec/orm/mongo_mapper.rb +0 -1
  78. data/spec/orm/mongoid.rb +4 -0
  79. data/spec/rails_app/app/controllers/sorcery_controller.rb +62 -1
  80. data/spec/rails_app/app/{datamapper → data_mapper}/authentication.rb +0 -0
  81. data/spec/rails_app/app/{datamapper → data_mapper}/user.rb +0 -0
  82. data/spec/rails_app/app/mongo_mapper/user.rb +2 -0
  83. data/spec/rails_app/config/routes.rb +9 -0
  84. data/spec/rails_app/db/migrate/core/20101224223620_create_users.rb +2 -2
  85. data/spec/shared_examples/user_activation_shared_examples.rb +7 -7
  86. data/spec/shared_examples/user_activity_logging_shared_examples.rb +73 -5
  87. data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +127 -9
  88. data/spec/shared_examples/user_oauth_shared_examples.rb +3 -6
  89. data/spec/shared_examples/user_remember_me_shared_examples.rb +6 -3
  90. data/spec/shared_examples/user_reset_password_shared_examples.rb +10 -10
  91. data/spec/shared_examples/user_shared_examples.rb +117 -30
  92. data/spec/spec_helper.rb +7 -22
  93. metadata +36 -58
  94. data/Gemfile.rails4 +0 -22
  95. data/VERSION +0 -1
  96. data/lib/sorcery/model/adapters/active_record.rb +0 -54
  97. data/lib/sorcery/model/adapters/datamapper.rb +0 -123
  98. data/lib/sorcery/model/adapters/mongo_mapper.rb +0 -60
  99. data/lib/sorcery/model/adapters/mongoid.rb +0 -88
  100. data/lib/sorcery/test_helpers/rails.rb +0 -7
  101. data/spec/active_record/controller_activity_logging_spec.rb +0 -29
  102. data/spec/active_record/controller_brute_force_protection_spec.rb +0 -158
  103. data/spec/active_record/controller_spec.rb +0 -8
  104. data/spec/active_record/integration_spec.rb +0 -23
  105. data/spec/datamapper/controller_activity_logging_spec.rb +0 -17
  106. data/spec/datamapper/controller_spec.rb +0 -8
  107. data/spec/datamapper/user_activity_logging_spec.rb +0 -9
  108. data/spec/mongo_mapper/controller_spec.rb +0 -8
  109. data/spec/mongoid/controller_activity_logging_spec.rb +0 -16
  110. data/spec/mongoid/controller_spec.rb +0 -8
  111. data/spec/rails_app/public/404.html +0 -26
  112. data/spec/rails_app/public/422.html +0 -26
  113. data/spec/rails_app/public/500.html +0 -26
  114. data/spec/rails_app/public/favicon.ico +0 -0
  115. data/spec/rails_app/public/images/rails.png +0 -0
  116. data/spec/rails_app/public/javascripts/application.js +0 -2
  117. data/spec/rails_app/public/javascripts/controls.js +0 -965
  118. data/spec/rails_app/public/javascripts/dragdrop.js +0 -974
  119. data/spec/rails_app/public/javascripts/effects.js +0 -1123
  120. data/spec/rails_app/public/javascripts/prototype.js +0 -6001
  121. data/spec/rails_app/public/javascripts/rails.js +0 -175
  122. data/spec/rails_app/public/robots.txt +0 -5
  123. data/spec/rails_app/public/stylesheets/.gitkeep +0 -0
  124. data/spec/shared_examples/controller_activity_logging_shared_examples.rb +0 -125
  125. data/spec/shared_examples/controller_oauth2_shared_examples.rb +0 -52
  126. data/spec/shared_examples/controller_oauth_shared_examples.rb +0 -62
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73519a45c58c078688dd72b3ef7dc52b2b05ba92
4
- data.tar.gz: a715fe10e2de64c09d76ec93e658849dd3b9112b
3
+ metadata.gz: f79fec92f71b24d1507e3848c0c943e3b8e7a6ed
4
+ data.tar.gz: bf2cfc0eb30778fbb3eb85f896a9b73811a179c4
5
5
  SHA512:
6
- metadata.gz: 08d0df3e5b8970ec81233d6dbb373cdabb4ff0e219dce27c7c790756507a36d683557ca11d19b70ea8e85217646ef20259892b6e0ee55f8d35c7d25cfb8df636
7
- data.tar.gz: 66cb33e9e89b23036e1470bf0b937da42e68828ecdb821bc736b471cf938c23fa9eb53911ac35050704748ebdfd1790caa27af12ee97fdd26b58c7fae4cf30f9
6
+ metadata.gz: d48170391dc1db75bb8bc88ce444ecc8d957796e0aaf96c29cafc4a01493689bc52e47ecaa5c0968c3aced147d623d2623f9dbe56e3dfdf46bf5309b005345f6
7
+ data.tar.gz: 4101544b567f3cb86c02bda20721a864b9c32fb688d62e64e7eee7fc0672614d06e0d8c004c8fa494113a9c834c1a09df1be91454ee00ee58865fcd31d01d7e0
data/.gitignore CHANGED
@@ -52,4 +52,5 @@ spec/rails_app/log/*
52
52
  *.sqlite3
53
53
  Gemfile*.lock
54
54
  gemfiles/*.lock
55
- .ruby-version
55
+ .ruby-version
56
+ tags
@@ -8,30 +8,19 @@ services: mongodb
8
8
 
9
9
  gemfile:
10
10
  - Gemfile
11
- - Gemfile.rails4
12
11
 
13
12
  env:
14
13
  - "SORCERY_ORM=active_record"
15
14
  - "SORCERY_ORM=mongoid"
16
15
  - "SORCERY_ORM=mongo_mapper"
17
- - "SORCERY_ORM=datamapper"
16
+ - "SORCERY_ORM=data_mapper"
18
17
 
19
18
  before_script:
20
19
  - mysql -e 'create database sorcery_test;'
21
20
 
22
21
  matrix:
23
- exclude:
24
- - rvm: 1.9.3
25
- gemfile: Gemfile.rails4
26
- env: "SORCERY_ORM=datamapper"
27
-
28
- - rvm: 2.0.0
29
- gemfile: Gemfile.rails4
30
- env: "SORCERY_ORM=datamapper"
31
-
32
- - rvm: 2.1
33
- gemfile: Gemfile.rails4
34
- env: "SORCERY_ORM=datamapper"
22
+ allow_failures:
23
+ - rvm: :jruby
35
24
 
36
25
  include:
37
26
  - rvm: 1.9.3
@@ -46,6 +35,10 @@ matrix:
46
35
  gemfile: gemfiles/mongoid-rails41.gemfile
47
36
  env: "SORCERY_ORM=mongoid"
48
37
 
38
+ - rvm: jruby
39
+ gemfile: gemfiles/mongoid-rails41.gemfile
40
+ env: "SORCERY_ORM=mongoid"
41
+
49
42
  - rvm: 1.9.3
50
43
  gemfile: gemfiles/mongo_mapper-rails41.gemfile
51
44
  env: "SORCERY_ORM=mongo_mapper"
@@ -58,6 +51,10 @@ matrix:
58
51
  gemfile: gemfiles/mongo_mapper-rails41.gemfile
59
52
  env: "SORCERY_ORM=mongo_mapper"
60
53
 
54
+ - rvm: jruby
55
+ gemfile: gemfiles/mongo_mapper-rails41.gemfile
56
+ env: "SORCERY_ORM=mongo_mapper"
57
+
61
58
  - rvm: 1.9.3
62
59
  gemfile: gemfiles/active_record-rails41.gemfile
63
60
  env: "SORCERY_ORM=active_record"
@@ -69,3 +66,67 @@ matrix:
69
66
  - rvm: 2.1
70
67
  gemfile: gemfiles/active_record-rails41.gemfile
71
68
  env: "SORCERY_ORM=active_record"
69
+
70
+ - rvm: jruby
71
+ gemfile: gemfiles/active_record-rails41.gemfile
72
+ env: "SORCERY_ORM=active_record"
73
+
74
+ - rvm: 1.9.3
75
+ gemfile: gemfiles/mongoid-rails40.gemfile
76
+ env: "SORCERY_ORM=mongoid"
77
+
78
+ - rvm: 2.0.0
79
+ gemfile: gemfiles/mongoid-rails40.gemfile
80
+ env: "SORCERY_ORM=mongoid"
81
+
82
+ - rvm: 2.1
83
+ gemfile: gemfiles/mongoid-rails40.gemfile
84
+ env: "SORCERY_ORM=mongoid"
85
+
86
+ - rvm: jruby
87
+ gemfile: gemfiles/mongoid-rails40.gemfile
88
+ env: "SORCERY_ORM=mongoid"
89
+
90
+ - rvm: 1.9.3
91
+ gemfile: gemfiles/mongo_mapper-rails40.gemfile
92
+ env: "SORCERY_ORM=mongo_mapper"
93
+
94
+ - rvm: 2.0.0
95
+ gemfile: gemfiles/mongo_mapper-rails40.gemfile
96
+ env: "SORCERY_ORM=mongo_mapper"
97
+
98
+ - rvm: 2.1
99
+ gemfile: gemfiles/mongo_mapper-rails40.gemfile
100
+ env: "SORCERY_ORM=mongo_mapper"
101
+
102
+ - rvm: jruby
103
+ gemfile: gemfiles/mongo_mapper-rails40.gemfile
104
+ env: "SORCERY_ORM=mongo_mapper"
105
+
106
+ - rvm: 1.9.3
107
+ gemfile: gemfiles/active_record-rails40.gemfile
108
+ env: "SORCERY_ORM=active_record"
109
+
110
+ - rvm: 2.0.0
111
+ gemfile: gemfiles/active_record-rails40.gemfile
112
+ env: "SORCERY_ORM=active_record"
113
+
114
+ - rvm: 2.1
115
+ gemfile: gemfiles/active_record-rails40.gemfile
116
+ env: "SORCERY_ORM=active_record"
117
+
118
+ - rvm: jruby
119
+ gemfile: gemfiles/active_record-rails40.gemfile
120
+ env: "SORCERY_ORM=active_record"
121
+
122
+ - rvm: 1.9.3
123
+ gemfile: gemfiles/mongoid3-rails32.gemfile
124
+ env: "SORCERY_ORM=mongoid"
125
+
126
+ - rvm: 2.0.0
127
+ gemfile: gemfiles/mongoid3-rails32.gemfile
128
+ env: "SORCERY_ORM=mongoid"
129
+
130
+ - rvm: 2.1
131
+ gemfile: gemfiles/mongoid3-rails32.gemfile
132
+ env: "SORCERY_ORM=mongoid"
@@ -1,6 +1,28 @@
1
1
  # Changelog
2
2
 
3
- ## 0.8.6 (not released)
3
+ ## 1.0 (not released yet)
4
+
5
+ * Adapters (Mongoid, MongoMapper, DataMapper) are now separated from the core Sorcery repo and moved under `sorcery-rails` organization. Special thanks to @juike!
6
+
7
+ ## 0.9.0
8
+
9
+ * Sending emails works with Rails 4.2 (thanks to @wooly)
10
+ * Added `valid_password?` method
11
+ * Added support for JIRA OAuth (thanks to @camilasan)
12
+ * Added support for Heroku OAuth (thanks to @tyrauber)
13
+ * Added support for Salesforce OAuth (thanks to @supremebeing7)
14
+ * Added support for Mongoid 4
15
+ * Fixed issues with empty passwords (thanks to @Borzik)
16
+ * `find_by_provider_and_uid` method was replaced with `find_by_oauth_credentials`
17
+ * Sorcery::VERSION constant was added to allow easy version check
18
+ * `@user.setup_activation` method was made to be public (thanks @iTakeshi)
19
+ * `current_users` method is deprecated
20
+ * Fetching email from VK auth, thanks to @makaroni4
21
+ * Add logged_in? method to test_helpers (thanks to @oriolbcn)
22
+ * #locked? method is now public API (thanks @rogercampos)
23
+ * Introduces a new User instance method `generate_reset_password_token` to generate a new reset password token without sending an email (thanks to @tbuehl)
24
+
25
+ ## 0.8.6
4
26
 
5
27
  * `current_user` returns `nil` instead of `false` if there's no user loggd in (#493)
6
28
  * MongoMapper adapter does not override `save!` method anymore. However due to ORM's lack of support for `validate: false` in `save!`, the combination of `validate: false` and `raise_on_failure: true` is not possible in MongoMapper. The errors will not be raised in this situation. (#151)
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 3.2'
4
4
  gem 'sqlite3'
5
+ gem 'pry'
5
6
 
6
7
  group :mongomapper do
7
8
  gem 'mongo_mapper'
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![Build Status](https://travis-ci.org/NoamB/sorcery.svg?branch=master)](https://travis-ci.org/NoamB/sorcery)
2
2
  [![Code Climate](https://codeclimate.com/github/NoamB/sorcery.png)](https://codeclimate.com/github/NoamB/sorcery)
3
+ [![Inline docs](http://inch-ci.org/github/NoamB/sorcery.png?branch=master)](http://inch-ci.org/github/NoamB/sorcery)
3
4
 
4
5
  # sorcery
5
6
  Magical Authentication for Rails 3 and 4. Supports ActiveRecord,
@@ -9,9 +10,11 @@ Inspired by restful_authentication, Authlogic and Devise. Crypto code taken
9
10
  almost unchanged from Authlogic. OAuth code inspired by OmniAuth and Ryan
10
11
  Bates's railscasts about it.
11
12
 
12
- **Rails 4 status:** [Sorcery 0.8.5](http://rubygems.org/gems/sorcery/versions/0.8.5) is fully tested and ready for Rails 4.0.
13
+ **What's happening now?** We are working on 1.0 version, which will include some API-breaking changes. It should be released about April 2015.
14
+ Until then we'll continue releasing `0.9.x` version with bug fixed.
13
15
 
14
- **Rails 4.1 status:** Sorcery 0.8.6 (to be released, currently in master branch) works with Rails 4.1
16
+ **Rails 4 status:** [Sorcery 0.9.0](http://rubygems.org/gems/sorcery/versions/0.9.0) is fully tested and ready for Rails 4.0, 4.1 and 4.2.
17
+ **Mongoid status:** Version 0.9.0 works with Mongoid 4.
15
18
 
16
19
  https://github.com/NoamB/sorcery/wiki/Simple-Password-Authentication
17
20
 
@@ -33,94 +36,116 @@ can write your own authentication flow. It was built with a few goals in mind:
33
36
 
34
37
  Hopefully, I've achieved this. If not, let me know.
35
38
 
36
- ## Useful Links:
39
+ ## Useful Links
37
40
 
38
- Railscast: http://railscasts.com/episodes/283-authentication-with-sorcery
41
+ [Documentation](http://rubydoc.info/gems/sorcery) |
42
+ [Railscast](http://railscasts.com/episodes/283-authentication-with-sorcery) | [Simple tutorial](https://github.com/NoamB/sorcery/wiki/Simple-Password-Authentication) | [Example Rails 3 app](https://github.com/NoamB/sorcery-example-app)
39
43
 
40
- Example Rails 3 app using sorcery:
41
- https://github.com/NoamB/sorcery-example-app
42
-
43
- Documentation: http://rubydoc.info/gems/sorcery
44
-
45
- Check out the tutorials in the github wiki!
44
+ Check out the tutorials in the [Wiki](https://github.com/NoamB/sorcery/wiki) for more!
46
45
 
47
46
  ## API Summary
48
47
 
49
48
  Below is a summary of the library methods. Most method names are self
50
49
  explaining and the rest are commented:
51
50
 
52
- # core
53
- require_login # this is a before filter
54
- login(email, password, remember_me = false)
55
- auto_login(user)# login without credentials
56
- logout
57
- logged_in? # available to view
58
- current_user # available to view
59
- redirect_back_or_to # used when a user tries to access a page while logged out, is asked to login, and we want to return him back to the page he originally wanted.
60
- @user.external? # external users, such as facebook/twitter etc.
61
- User.authenticates_with_sorcery!
62
-
63
- # activity logging
64
- current_users
65
-
66
- # http basic auth
67
- require_login_from_http_basic # this is a before filter
68
-
69
- # external
70
- login_at(provider) # sends the user to an external service (twitter etc.) to authenticate.
71
- login_from(provider) # tries to login from the external provider's callback.
72
- create_from(provider) # create the user in the local app db.
73
-
74
- # remember me
75
- auto_login(user, should_remember=false) # login without credentials, optional remember_me
76
- remember_me!
77
- forget_me!
78
-
79
- # reset password
80
- User.load_from_reset_password_token(token)
81
- @user.deliver_reset_password_instructions!
82
- @user.change_password!(new_password)
83
-
84
- # user activation
85
- User.load_from_activation_token(token)
86
- @user.activate!
51
+
52
+ ### core
53
+ ```ruby
54
+ require_login # this is a before filter
55
+ login(email, password, remember_me = false)
56
+ auto_login(user)# login without credentials
57
+ logout
58
+ logged_in? # available to view
59
+ current_user # available to view
60
+ redirect_back_or_to # used when a user tries to access a page while logged out, is asked to login, and we want to return him back to the page he originally wanted.
61
+ @user.external? # external users, such as facebook/twitter etc.
62
+ User.authenticates_with_sorcery!
63
+ ```
64
+
65
+ ### http basic auth
66
+ ```ruby
67
+ require_login_from_http_basic # this is a before filter
68
+ ```
69
+
70
+ ### external
71
+ ```ruby
72
+ login_at(provider) # sends the user to an external service (twitter etc.) to authenticate.
73
+ login_from(provider) # tries to login from the external provider's callback.
74
+ create_from(provider) # create the user in the local app db.
75
+ ```
76
+
77
+ ### remember me
78
+ ```ruby
79
+ auto_login(user, should_remember=false) # login without credentials, optional remember_me
80
+ remember_me!
81
+ forget_me!
82
+ ```
83
+
84
+ ### reset password
85
+ ```ruby
86
+ User.load_from_reset_password_token(token)
87
+ @user.generate_reset_password_token! # if you want to send the email by youself
88
+ @user.deliver_reset_password_instructions! # generates the token and sends the email
89
+ @user.change_password!(new_password)
90
+ ```
91
+
92
+ ### user activation
93
+ ```ruby
94
+ User.load_from_activation_token(token)
95
+ @user.setup_activation
96
+ @user.activate!
97
+ ```
87
98
 
88
99
  Please see the tutorials in the github wiki for detailed usage information.
89
100
 
90
- ## Installation:
101
+ ## Installation
91
102
 
92
103
  If using bundler, first add 'sorcery' to your Gemfile:
93
104
 
94
- gem "sorcery"
105
+ ```ruby
106
+ gem "sorcery"
107
+ ```
95
108
 
96
109
  And run
97
110
 
98
- bundle install
111
+ ```ruby
112
+ bundle install
113
+ ```
99
114
 
100
115
  Otherwise simply
101
116
 
102
- gem install sorcery
117
+ ```ruby
118
+ gem install sorcery
119
+ ```
103
120
 
104
- ## Rails configuration:
121
+ ## Rails configuration
105
122
 
106
- rails generate sorcery:install
123
+ ```bash
124
+ rails generate sorcery:install
125
+ ```
107
126
 
108
127
  This will generate the core migration file, the initializer file and the
109
128
  'User' model class.
110
129
 
111
- rails generate sorcery:install remember_me reset_password
130
+ ```bash
131
+ rails generate sorcery:install remember_me reset_password
132
+ ```
112
133
 
113
134
  This will generate the migrations files for remember_me and reset_password
114
135
  submodules and will create the initializer file (and add submodules to it),
115
136
  and create the 'User' model class.
116
137
 
117
- rails generate sorcery:install --model Person
138
+ ```bash
139
+ rails generate sorcery:install --model Person
140
+ ```
118
141
 
119
142
  This will generate the core migration file, the initializer and change the
120
143
  model class (in the initializer and migration files) to the class 'Person'
121
144
  (and its pluralized version, 'people')
122
145
 
123
- rails generate sorcery:install http_basic_auth external remember_me --migrations
146
+ ```bash
147
+ rails generate sorcery:install http_basic_auth external remember_me --only-submodules
148
+ ```
124
149
 
125
150
  This will generate only the migration files for the specified submodules and
126
151
  will add them to the initializer file.
@@ -136,25 +161,29 @@ After implementing the `delayed_job` into your project add the code below at
136
161
  the end of the `config/initializers/sorcery.rb` file. After that all emails
137
162
  will be sent asynchronously.
138
163
 
139
- module Sorcery
140
- module Model
141
- module InstanceMethods
142
- def generic_send_email(method, mailer)
143
- config = sorcery_config
144
- mail = config.send(mailer).delay.send(config.send(method), self)
145
- end
146
- end
164
+ ```ruby
165
+ module Sorcery
166
+ module Model
167
+ module InstanceMethods
168
+ def generic_send_email(method, mailer)
169
+ config = sorcery_config
170
+ mail = config.send(mailer).delay.send(config.send(method), self)
147
171
  end
148
172
  end
173
+ end
174
+ end
175
+ ```
149
176
 
150
177
  Sidekiq and Resque integrations are coming soon.
151
178
 
152
179
  ## Single Table Inheritance (STI) Support
153
180
  STI is supported via a single setting in config/initializers/sorcery.rb.
154
181
 
155
- ## Full Features List by module:
182
+ ## Full Features List by module
183
+
184
+ **Core** (see [lib/sorcery/model.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/model.rb) and
185
+ [lib/sorcery/controller.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/controller.rb)):
156
186
 
157
- Core (see lib/sorcery/model.rb and lib/sorcery/controller.rb):
158
187
  * login/logout, optional return user to requested url on login, configurable
159
188
  redirect for non-logged-in users.
160
189
  * password encryption, algorithms: bcrypt(default), md5, sha1, sha256,
@@ -163,7 +192,8 @@ Core (see lib/sorcery/model.rb and lib/sorcery/controller.rb):
163
192
  * allow multiple fields to serve as username.
164
193
 
165
194
 
166
- User Activation (see lib/sorcery/model/submodules/user_activation.rb):
195
+ **User Activation** (see [lib/sorcery/model/submodules/user_activation.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/model/submodules/user_activation.rb)):
196
+
167
197
  * User activation by email with optional success email.
168
198
  * configurable attribute names.
169
199
  * configurable mailer, method name, and attribute name.
@@ -171,37 +201,41 @@ User Activation (see lib/sorcery/model/submodules/user_activation.rb):
171
201
  * Optionally prevent non-active users to login.
172
202
 
173
203
 
174
- Reset Password (see lib/sorcery/model/submodules/reset_password.rb):
204
+ **Reset Password** (see [lib/sorcery/model/submodules/reset_password.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/model/submodules/reset_password.rb)):
205
+
175
206
  * Reset password with email verification.
176
207
  * configurable mailer, method name, and attribute name.
177
208
  * configurable temporary token expiration.
178
209
  * configurable time between emails (hammering protection).
179
210
 
180
211
 
181
- Remember Me (see lib/sorcery/model/submodules/remember_me.rb):
212
+ **Remember Me** (see [lib/sorcery/model/submodules/remember_me.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/model/submodules/remember_me.rb)):
213
+
182
214
  * Remember me with configurable expiration.
183
215
  * configurable attribute names.
184
216
 
185
217
 
186
- Session Timeout (see lib/sorcery/controller/submodules/session_timeout.rb):
218
+ **Session Timeout** (see [lib/sorcery/controller/submodules/session_timeout.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/controller/submodules/session_timeout.rb)):
219
+
187
220
  * Configurable session timeout.
188
221
  * Optionally session timeout will be calculated from last user action.
189
222
 
190
223
 
191
- Brute Force Protection (see
192
- lib/sorcery/model/submodules/brute_force_protection.rb):
224
+ **Brute Force Protection** (see [lib/sorcery/model/submodules/brute_force_protection.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/model/submodules/brute_force_protection.rb)):
225
+
193
226
  * Brute force login hammering protection.
194
227
  * configurable logins before lock and lock duration.
195
228
 
196
229
 
197
- Basic HTTP Authentication (see
198
- lib/sorcery/controller/submodules/http_basic_auth.rb):
230
+ **Basic HTTP Authentication** (see [lib/sorcery/controller/submodules/http_basic_auth.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/controller/submodules/http_basic_auth.rb)):
231
+
199
232
  * A before filter for requesting authentication with HTTP Basic.
200
233
  * automatic login from HTTP Basic.
201
234
  * automatic login is disabled if session key changed.
202
235
 
203
236
 
204
- Activity Logging (see lib/sorcery/model/submodules/activity_logging.rb):
237
+ **Activity Logging** (see [lib/sorcery/model/submodules/activity_logging.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/model/submodules/activity_logging.rb)):
238
+
205
239
  * automatic logging of last login, last logout, last activity time and IP
206
240
  address for last login.
207
241
  * an easy method of collecting the list of currently logged in users.
@@ -209,15 +243,17 @@ Activity Logging (see lib/sorcery/model/submodules/activity_logging.rb):
209
243
  list of logged in users.
210
244
 
211
245
 
212
- External (see lib/sorcery/controller/submodules/external.rb):
213
- * OAuth1 and OAuth2 support (currently: Twitter, Facebook, Github, Google,
214
- LinkedIn, VK, LiveID and Xing)
246
+ **External** (see [lib/sorcery/controller/submodules/external.rb](https://github.com/NoamB/sorcery/blob/master/lib/sorcery/controller/submodules/external.rb)):
247
+
248
+ * OAuth1 and OAuth2 support (currently: Twitter, Facebook, Github, Google, Heroku,
249
+ LinkedIn, VK, LiveID, Xing, and Salesforce)
215
250
  * configurable db field names and authentications table.
216
251
 
217
252
 
218
- ## Next Planned Features:
253
+ ## Next Planned Features
219
254
 
220
255
  I've got some thoughts which include (unordered):
256
+
221
257
  * Passing a block to encrypt, allowing the developer to define his own mix
222
258
  of salting and encrypting
223
259
  * Forgot username, maybe as part of the reset_password module
@@ -252,20 +288,26 @@ Important notes:
252
288
  * Usage: include DataMapper::Resource in user model, follow sorcery
253
289
  instructions (remember to add property id, validators and accessor
254
290
  attributes such as password and password_confirmation)
255
- * Option downcase__username_before_authenticating and dm-mysql,
291
+ * Option downcase__username_before_authenticating and dm-mysql,
256
292
  http://datamapper.lighthouseapp.com/projects/20609/tickets/1105-add-support-for-definingchanging-default-collation
257
293
 
258
294
  ## Upgrading
259
295
 
260
296
  Important notes while upgrading:
261
297
 
298
+ * If you are upgrading from <= **0.8.6** and you use Sorcery model methods in your app,
299
+ you might need to change them from `user.method` to `user.sorcery_adapter.method` and from
300
+ `User.method` to `User.sorcery_adapter_method`
301
+
262
302
  * If you are upgrading from <= **0.8.5** and you're using Sorcery test helpers,
263
303
  you need to change the way you include them to following code:
264
304
 
265
- RSpec.configure do |config|
266
- config.include Sorcery::TestHelpers::Rails::Controler, type: [:controller]
267
- config.include Sorcery::TestHelpers::Rails::Integration, type: [:feature]
268
- end
305
+ ```ruby
306
+ RSpec.configure do |config|
307
+ config.include Sorcery::TestHelpers::Rails::Controller, type: :controller
308
+ config.include Sorcery::TestHelpers::Rails::Integration, type: :feature
309
+ end
310
+ ```
269
311
 
270
312
  * If are upgrading to **0.8.2** and use activity_logging feature with
271
313
  ActiveRecord, you will have to add a new column
@@ -274,12 +316,15 @@ Important notes while upgrading:
274
316
  * Sinatra support existed until **v0.7.0** (including), but was dropped
275
317
  later due to being a maintenance nightmare.
276
318
  * If upgrading from <= **0.6.1 to >= **0.7.0** you need to change
277
- 'username_attribute_name' to 'username_attribute_names' in initializer.
319
+ 'username
320
+ _attribute_name' to 'username_attribute_names' in initializer.
278
321
  * If upgrading from <= **v0.5.1** to >= **v0.5.2** you need to explicitly
279
322
  set your user_class model in the initializer file.
280
323
 
281
- # This line must come after the 'user config' block.
282
- config.user_class = User
324
+ ```ruby
325
+ # This line must come after the 'user config' block.
326
+ config.user_class = User
327
+ ```
283
328
 
284
329
 
285
330
  ## Contributing to sorcery
@@ -314,7 +359,13 @@ email: shatrov@me.com
314
359
 
315
360
  twitter: @Kiiiir
316
361
 
362
+ #### Grzegorz Witek
363
+
364
+ email: arnvald.to@gmail.com
365
+
366
+ twitter: @arnvald
367
+
317
368
  ## Copyright
318
369
 
319
- Copyright (c) 2010 Noam Ben Ari (nbenari@gmail.com). See LICENSE.txt for
370
+ Copyright (c) 2010-2014 Noam Ben Ari (nbenari@gmail.com). See LICENSE.txt for
320
371
  further details.