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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +75 -14
- data/CHANGELOG.md +23 -1
- data/Gemfile +1 -0
- data/README.md +137 -86
- data/gemfiles/active_record-rails40.gemfile +7 -0
- data/gemfiles/active_record-rails41.gemfile +3 -2
- data/gemfiles/mongo_mapper-rails40.gemfile +9 -0
- data/gemfiles/mongo_mapper-rails41.gemfile +2 -1
- data/gemfiles/mongoid-rails40.gemfile +9 -0
- data/gemfiles/mongoid-rails41.gemfile +3 -5
- data/gemfiles/mongoid3-rails32.gemfile +9 -0
- data/lib/generators/sorcery/USAGE +1 -1
- data/lib/generators/sorcery/install_generator.rb +19 -5
- data/lib/generators/sorcery/templates/initializer.rb +34 -9
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +3 -1
- data/lib/generators/sorcery/templates/migration/core.rb +2 -2
- data/lib/generators/sorcery/templates/migration/external.rb +3 -1
- data/lib/sorcery.rb +75 -43
- data/lib/sorcery/adapters/active_record_adapter.rb +120 -0
- data/lib/sorcery/adapters/base_adapter.rb +30 -0
- data/lib/sorcery/adapters/data_mapper_adapter.rb +176 -0
- data/lib/sorcery/adapters/mongo_mapper_adapter.rb +110 -0
- data/lib/sorcery/adapters/mongoid_adapter.rb +97 -0
- data/lib/sorcery/controller.rb +5 -64
- data/lib/sorcery/controller/config.rb +65 -0
- data/lib/sorcery/controller/submodules/activity_logging.rb +16 -21
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +6 -6
- data/lib/sorcery/controller/submodules/external.rb +8 -28
- data/lib/sorcery/controller/submodules/remember_me.rb +4 -4
- data/lib/sorcery/controller/submodules/session_timeout.rb +10 -6
- data/lib/sorcery/model.rb +43 -175
- data/lib/sorcery/model/config.rb +96 -0
- data/lib/sorcery/model/submodules/activity_logging.rb +29 -36
- data/lib/sorcery/model/submodules/brute_force_protection.rb +21 -37
- data/lib/sorcery/model/submodules/external.rb +53 -9
- data/lib/sorcery/model/submodules/remember_me.rb +12 -31
- data/lib/sorcery/model/submodules/reset_password.rb +21 -39
- data/lib/sorcery/model/submodules/user_activation.rb +21 -63
- data/lib/sorcery/model/temporary_token.rb +4 -4
- data/lib/sorcery/providers/base.rb +11 -0
- data/lib/sorcery/providers/facebook.rb +1 -1
- data/lib/sorcery/providers/github.rb +1 -1
- data/lib/sorcery/providers/google.rb +1 -1
- data/lib/sorcery/providers/heroku.rb +57 -0
- data/lib/sorcery/providers/jira.rb +77 -0
- data/lib/sorcery/providers/linkedin.rb +1 -1
- data/lib/sorcery/providers/liveid.rb +1 -1
- data/lib/sorcery/providers/salesforce.rb +50 -0
- data/lib/sorcery/providers/twitter.rb +1 -1
- data/lib/sorcery/providers/vk.rb +6 -4
- data/lib/sorcery/providers/xing.rb +1 -1
- data/lib/sorcery/test_helpers/internal.rb +7 -3
- data/lib/sorcery/test_helpers/rails/controller.rb +5 -1
- data/lib/sorcery/version.rb +3 -0
- data/sorcery.gemspec +6 -2
- data/spec/active_record/user_activity_logging_spec.rb +9 -0
- data/spec/controllers/controller_activity_logging_spec.rb +124 -0
- data/spec/controllers/controller_brute_force_protection_spec.rb +43 -0
- data/spec/{active_record → controllers}/controller_http_basic_auth_spec.rb +14 -11
- data/spec/{active_record → controllers}/controller_oauth2_spec.rb +128 -56
- data/spec/{active_record → controllers}/controller_oauth_spec.rb +94 -70
- data/spec/{active_record → controllers}/controller_remember_me_spec.rb +32 -12
- data/spec/{active_record → controllers}/controller_session_timeout_spec.rb +15 -5
- data/spec/{shared_examples/controller_shared_examples.rb → controllers/controller_spec.rb} +34 -19
- data/spec/{datamapper → data_mapper}/user_activation_spec.rb +1 -1
- data/spec/data_mapper/user_activity_logging_spec.rb +14 -0
- data/spec/{datamapper → data_mapper}/user_brute_force_protection_spec.rb +1 -1
- data/spec/{datamapper → data_mapper}/user_oauth_spec.rb +1 -1
- data/spec/{datamapper → data_mapper}/user_remember_me_spec.rb +1 -1
- data/spec/{datamapper → data_mapper}/user_reset_password_spec.rb +1 -1
- data/spec/{datamapper → data_mapper}/user_spec.rb +1 -1
- data/spec/mongoid/user_spec.rb +13 -0
- data/spec/orm/active_record.rb +12 -0
- data/spec/orm/{datamapper.rb → data_mapper.rb} +16 -2
- data/spec/orm/mongo_mapper.rb +0 -1
- data/spec/orm/mongoid.rb +4 -0
- data/spec/rails_app/app/controllers/sorcery_controller.rb +62 -1
- data/spec/rails_app/app/{datamapper → data_mapper}/authentication.rb +0 -0
- data/spec/rails_app/app/{datamapper → data_mapper}/user.rb +0 -0
- data/spec/rails_app/app/mongo_mapper/user.rb +2 -0
- data/spec/rails_app/config/routes.rb +9 -0
- data/spec/rails_app/db/migrate/core/20101224223620_create_users.rb +2 -2
- data/spec/shared_examples/user_activation_shared_examples.rb +7 -7
- data/spec/shared_examples/user_activity_logging_shared_examples.rb +73 -5
- data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +127 -9
- data/spec/shared_examples/user_oauth_shared_examples.rb +3 -6
- data/spec/shared_examples/user_remember_me_shared_examples.rb +6 -3
- data/spec/shared_examples/user_reset_password_shared_examples.rb +10 -10
- data/spec/shared_examples/user_shared_examples.rb +117 -30
- data/spec/spec_helper.rb +7 -22
- metadata +36 -58
- data/Gemfile.rails4 +0 -22
- data/VERSION +0 -1
- data/lib/sorcery/model/adapters/active_record.rb +0 -54
- data/lib/sorcery/model/adapters/datamapper.rb +0 -123
- data/lib/sorcery/model/adapters/mongo_mapper.rb +0 -60
- data/lib/sorcery/model/adapters/mongoid.rb +0 -88
- data/lib/sorcery/test_helpers/rails.rb +0 -7
- data/spec/active_record/controller_activity_logging_spec.rb +0 -29
- data/spec/active_record/controller_brute_force_protection_spec.rb +0 -158
- data/spec/active_record/controller_spec.rb +0 -8
- data/spec/active_record/integration_spec.rb +0 -23
- data/spec/datamapper/controller_activity_logging_spec.rb +0 -17
- data/spec/datamapper/controller_spec.rb +0 -8
- data/spec/datamapper/user_activity_logging_spec.rb +0 -9
- data/spec/mongo_mapper/controller_spec.rb +0 -8
- data/spec/mongoid/controller_activity_logging_spec.rb +0 -16
- data/spec/mongoid/controller_spec.rb +0 -8
- data/spec/rails_app/public/404.html +0 -26
- data/spec/rails_app/public/422.html +0 -26
- data/spec/rails_app/public/500.html +0 -26
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/images/rails.png +0 -0
- data/spec/rails_app/public/javascripts/application.js +0 -2
- data/spec/rails_app/public/javascripts/controls.js +0 -965
- data/spec/rails_app/public/javascripts/dragdrop.js +0 -974
- data/spec/rails_app/public/javascripts/effects.js +0 -1123
- data/spec/rails_app/public/javascripts/prototype.js +0 -6001
- data/spec/rails_app/public/javascripts/rails.js +0 -175
- data/spec/rails_app/public/robots.txt +0 -5
- data/spec/rails_app/public/stylesheets/.gitkeep +0 -0
- data/spec/shared_examples/controller_activity_logging_shared_examples.rb +0 -125
- data/spec/shared_examples/controller_oauth2_shared_examples.rb +0 -52
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f79fec92f71b24d1507e3848c0c943e3b8e7a6ed
|
4
|
+
data.tar.gz: bf2cfc0eb30778fbb3eb85f896a9b73811a179c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d48170391dc1db75bb8bc88ce444ecc8d957796e0aaf96c29cafc4a01493689bc52e47ecaa5c0968c3aced147d623d2623f9dbe56e3dfdf46bf5309b005345f6
|
7
|
+
data.tar.gz: 4101544b567f3cb86c02bda20721a864b9c32fb688d62e64e7eee7fc0672614d06e0d8c004c8fa494113a9c834c1a09df1be91454ee00ee58865fcd31d01d7e0
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -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=
|
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
|
-
|
24
|
-
- rvm:
|
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"
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 0
|
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
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
|
-
**
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
105
|
+
```ruby
|
106
|
+
gem "sorcery"
|
107
|
+
```
|
95
108
|
|
96
109
|
And run
|
97
110
|
|
98
|
-
|
111
|
+
```ruby
|
112
|
+
bundle install
|
113
|
+
```
|
99
114
|
|
100
115
|
Otherwise simply
|
101
116
|
|
102
|
-
|
117
|
+
```ruby
|
118
|
+
gem install sorcery
|
119
|
+
```
|
103
120
|
|
104
|
-
## Rails configuration
|
121
|
+
## Rails configuration
|
105
122
|
|
106
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
214
|
-
|
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
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
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
|
-
'
|
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
|
-
|
282
|
-
|
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.
|