simple_token_authentication 1.14.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NjIyYWI3MGE1N2VkNTY2ZTRhNjNmZWZjYzVmNjgwZmJkZWU2ODI3Mg==
5
- data.tar.gz: !binary |-
6
- OWRkMDUxNTA3MTBlNDhiYTk3NWE2ODJiOTZiMzUwZjlkYzg5MjBiNA==
2
+ SHA1:
3
+ metadata.gz: 3954e4aa1084737bfce46e449f442d59c41a8f06
4
+ data.tar.gz: 87f0de62bcce94ab8431f63f952e0a02417c7ec2
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NmQ5ZWRhNjM2MzMzY2ZhYjIyNDlkOTQ5NzQ2YzMyN2I1M2JhODc4NjkwNjM0
10
- NGU1MTkxNWE2YzgxNzE2NTg4ZWRkZWZiYmM4OWZmNDc3Mzg3NjJlYjVlYjUz
11
- Y2Q5ZDgwOWU4NWU1ZTdmMzZkNTM1YWYzN2FmYjI2ZDEyZjc5MjM=
12
- data.tar.gz: !binary |-
13
- NzZlODg5ZTk1YzY3ZDA2NmNlNjgxN2U1MGJiYTQyZjM5MDg4YjE4NmQ3NjY4
14
- YmRhMDVhZDEzNmM1NWYwYmRmZjZlODJhMjczMDAzZWUxNWI4OGY4YWY4YWY5
15
- NDFhYjZhNWMwY2ViNWM2Y2RjNzI0ZGE1OGM2ODM5NzczN2ExZWI=
6
+ metadata.gz: 44c18ed1a2446f3a064ca1b40fe168a55f90f4dee0ab7feb02a76e5abe439a1d572a81d7cd78fb85f2724b252c3d63f93bca13436cf9ab2d4c00536076c9e485
7
+ data.tar.gz: 5089b7ced8079351b5719e5c327ecddc006948daa9b8c604acb1df0b418260f5846cebddf728164df40db60ed4812e9f573cf2f8d2948467178ef4cd49e58271
data/Appraisals CHANGED
@@ -1,7 +1,5 @@
1
1
  appraise 'rails_5_devise_4' do
2
- # Until Mongoid 6 is released, allow Rails 5 dependencies to be installed,
3
- # see https://github.com/gonzalo-bulnes/simple_token_authentication/issues/231
4
- gem 'mongoid', git: 'https://github.com/mongodb/mongoid.git', branch: 'master'
2
+ # use gemspec constraints
5
3
  end
6
4
 
7
5
  appraise 'rails_4_devise_3' do
@@ -14,7 +12,8 @@ end
14
12
  appraise 'ruby_1.9.3_rails_3.2' do
15
13
  gem 'actionmailer', '>= 3.2.6', '< 4'
16
14
  gem 'actionpack', '>= 3.2.6', '< 4'
17
- gem 'activerecord', '>= 3.2.6', '< 4'
15
+ gem 'activerecord', '>= 3.2.15', '< 4'
18
16
  gem 'mime-types', '< 3'
17
+ gem 'term-ansicolor', '~> 1.3.0'
19
18
  gem 'tins', '< 1.7.0'
20
19
  end
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [1.15.0] - 2017-01-14
7
+
8
+ ### Added
9
+
10
+ - Support for hooks, specifically `after_successful_token_authentication` for now
11
+ - A Contributor Code of Conduct to ensure everyone feels safe contributing
12
+
6
13
  ## [1.14.0] - 2016-07-09
7
14
 
8
15
  ### Added
@@ -253,6 +260,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
253
260
  This [gist][gist] did refactor the Jose Valim's code into an `ActiveSupport::Concern`.
254
261
 
255
262
  [gist]: https://gist.github.com/gonzalo-bulnes/7659739
263
+ [1.15.0]: https://github.com/gonzalo-bulnes/simple_token_authentication/compare/v1.14.0...v1.15.0
256
264
  [1.14.0]: https://github.com/gonzalo-bulnes/simple_token_authentication/compare/v1.13.0...v1.14.0
257
265
  [1.13.0]: https://github.com/gonzalo-bulnes/simple_token_authentication/compare/v1.12.0...v1.13.0
258
266
  [1.12.0]: https://github.com/gonzalo-bulnes/simple_token_authentication/compare/v1.11.0...v1.12.0
data/README.md CHANGED
@@ -24,7 +24,9 @@ This gem packages the content of the gist and provides a set of convenient optio
24
24
  Installation
25
25
  ------------
26
26
 
27
- Install [Devise][devise] with any modules you want, then add the gem to your `Gemfile`:
27
+ ### In a nutshell
28
+
29
+ First install [Devise][devise] and configure it with any modules you want, then add the gem to your `Gemfile` and `bundle install`:
28
30
 
29
31
  ```ruby
30
32
  # Gemfile
@@ -32,6 +34,29 @@ Install [Devise][devise] with any modules you want, then add the gem to your `Ge
32
34
  gem 'simple_token_authentication', '~> 1.0' # see semver.org
33
35
  ```
34
36
 
37
+ Once that done, only two steps are required to setup token authentication:
38
+
39
+ 1. [Make one or more models token authenticatable][token_authenticatable] (ActiveRecord and Mongoid are supported)
40
+ 1. [Allow controllers to handle token authentication][token_authentication_handler] (Rails, Rails API, and `ActionController::Metal` are supported)
41
+
42
+ _If you want more details about how the gem works, keep reading! We'll get to these two steps after the overview._
43
+
44
+ [token_authenticatable]: #make-models-token-authenticatable
45
+ [token_authentication_handler]: #allow-controllers-to-handle-token-authentication
46
+
47
+ ### Overview
48
+
49
+ Simple Token Authentication provides the ability to manage an `authentication_token` from your model instances. A model with that ability enabled is said to be **token authenticatable** (typically, the `User` model will be made token authenticatable).
50
+
51
+ The gem also provides the ability for any controller to handle token authentication for one or multiple _token authenticatable_ models. That ability allows, for example, to automatically sign in an `user` when the correct credentials are provided with a request. A controller with that ability enabled is said to behave as a **token authentication handler**.
52
+ The token authentication credentials for a given request can be provided either in the form of [query params][authentication_method_query_params], or [HTTP headers][authentication_method_headers]. By default, the required credentials are the user's email and their authentication token.
53
+
54
+ What happens when a request is provided with no credentials or incorrect credentials is [highly configurable][integration_with_other_authentication_methods] (some scenarios may require access to be denied, other may allow unauthenticated access, or provide others strategies to authenticate users). By default, when token authentication fails, Devise is used as a fallback to ensure a consistent behaviour with controllers that do not handle token authentication.
55
+
56
+ [authentication_method_query_params]: #authentication-method-1-query-params
57
+ [authentication_method_headers]: #authentication-method-2-request-headers
58
+ [integration_with_other_authentication_methods]: #integration-with-other-authentication-and-authorization-methods
59
+
35
60
  ### Make models token authenticatable
36
61
 
37
62
  #### ActiveRecord
@@ -250,6 +275,27 @@ To use no fallback when token authentication fails, set `fallback: :none`.
250
275
 
251
276
  [csrf]: https://github.com/gonzalo-bulnes/simple_token_authentication/issues/49
252
277
 
278
+ ### Hooks
279
+
280
+ One hook is currently available to trigger custom behaviour after an user has been successfully authenticated through token authentication. To use it, override the `after_successful_token_authentication` method in the corresponding token authentication handler:
281
+
282
+ ```ruby
283
+ # app/controller/application_controller.rb
284
+
285
+ class ApplicationController < ActiveController::Base
286
+ acts_as_token_authentication_handler_for User
287
+
288
+ # ...
289
+
290
+ private
291
+
292
+ def after_successful_token_authentication
293
+ # Make the authentication token to be disposable - for example
294
+ renew_authentication_token!
295
+ end
296
+ end
297
+ ```
298
+
253
299
  ### Testing
254
300
 
255
301
  Here is an example of how you can test-drive your configuration using [Minitest][minitest]:
@@ -322,6 +368,10 @@ Contributions are welcome! I'm not personally maintaining any [list of contribut
322
368
 
323
369
  Please be sure to [review the open issues][open-questions] and contribute with your ideas or code in the issue best suited to the topic. Keeping discussions in a single place makes easier to everyone interested in that topic to keep track of the contributions.
324
370
 
371
+ Finally, please note that this project is released with a [Contributor Code of Conduct][coc]. By participating in this project you agree to abide by its terms.
372
+
373
+ [coc]: ./CODE_OF_CONDUCT.md
374
+
325
375
  Credits
326
376
  -------
327
377
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- simple_token_authentication (1.14.0)
4
+ simple_token_authentication (1.15.0)
5
5
  actionmailer (>= 3.2.6, < 6)
6
6
  actionpack (>= 3.2.6, < 6)
7
7
  devise (>= 3.2, < 6)
@@ -9,36 +9,36 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionmailer (4.2.6)
13
- actionpack (= 4.2.6)
14
- actionview (= 4.2.6)
15
- activejob (= 4.2.6)
12
+ actionmailer (4.2.7.1)
13
+ actionpack (= 4.2.7.1)
14
+ actionview (= 4.2.7.1)
15
+ activejob (= 4.2.7.1)
16
16
  mail (~> 2.5, >= 2.5.4)
17
17
  rails-dom-testing (~> 1.0, >= 1.0.5)
18
- actionpack (4.2.6)
19
- actionview (= 4.2.6)
20
- activesupport (= 4.2.6)
18
+ actionpack (4.2.7.1)
19
+ actionview (= 4.2.7.1)
20
+ activesupport (= 4.2.7.1)
21
21
  rack (~> 1.6)
22
22
  rack-test (~> 0.6.2)
23
23
  rails-dom-testing (~> 1.0, >= 1.0.5)
24
24
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
25
- actionview (4.2.6)
26
- activesupport (= 4.2.6)
25
+ actionview (4.2.7.1)
26
+ activesupport (= 4.2.7.1)
27
27
  builder (~> 3.1)
28
28
  erubis (~> 2.7.0)
29
29
  rails-dom-testing (~> 1.0, >= 1.0.5)
30
30
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
31
- activejob (4.2.6)
32
- activesupport (= 4.2.6)
31
+ activejob (4.2.7.1)
32
+ activesupport (= 4.2.7.1)
33
33
  globalid (>= 0.3.0)
34
- activemodel (4.2.6)
35
- activesupport (= 4.2.6)
34
+ activemodel (4.2.7.1)
35
+ activesupport (= 4.2.7.1)
36
36
  builder (~> 3.1)
37
- activerecord (4.2.6)
38
- activemodel (= 4.2.6)
39
- activesupport (= 4.2.6)
37
+ activerecord (4.2.7.1)
38
+ activemodel (= 4.2.7.1)
39
+ activesupport (= 4.2.7.1)
40
40
  arel (~> 6.0)
41
- activesupport (4.2.6)
41
+ activesupport (4.2.7.1)
42
42
  i18n (~> 0.7)
43
43
  json (~> 1.7, >= 1.7.7)
44
44
  minitest (~> 5.1)
@@ -48,12 +48,11 @@ GEM
48
48
  bundler
49
49
  rake
50
50
  thor (>= 0.14.0)
51
- arel (6.0.3)
51
+ arel (6.0.4)
52
52
  bcrypt (3.1.11)
53
- bson (3.2.6)
54
- builder (3.2.2)
53
+ bson (4.2.1)
54
+ builder (3.2.3)
55
55
  coderay (1.1.1)
56
- connection_pool (2.2.0)
57
56
  devise (3.5.10)
58
57
  bcrypt (~> 3.0)
59
58
  orm_adapter (~> 0.1)
@@ -63,7 +62,7 @@ GEM
63
62
  warden (~> 1.2.3)
64
63
  diff-lcs (1.2.5)
65
64
  erubis (2.7.0)
66
- globalid (0.3.6)
65
+ globalid (0.3.7)
67
66
  activesupport (>= 4.1.0)
68
67
  i18n (0.7.0)
69
68
  inch (0.7.1)
@@ -71,7 +70,7 @@ GEM
71
70
  sparkr (>= 0.2.0)
72
71
  term-ansicolor
73
72
  yard (~> 0.8.7.5)
74
- json (1.8.3)
73
+ json (1.8.6)
75
74
  loofah (2.0.3)
76
75
  nokogiri (>= 1.5.9)
77
76
  mail (2.6.4)
@@ -80,50 +79,47 @@ GEM
80
79
  mime-types (3.1)
81
80
  mime-types-data (~> 3.2015)
82
81
  mime-types-data (3.2016.0521)
83
- mini_portile2 (2.0.0)
84
- minitest (5.9.0)
85
- mongoid (4.0.2)
82
+ mini_portile2 (2.1.0)
83
+ minitest (5.10.1)
84
+ mongo (2.4.1)
85
+ bson (>= 4.2.1, < 5.0.0)
86
+ mongoid (5.1.6)
86
87
  activemodel (~> 4.0)
87
- moped (~> 2.0.0)
88
- origin (~> 2.1)
88
+ mongo (~> 2.1)
89
+ origin (~> 2.2)
89
90
  tzinfo (>= 0.3.37)
90
- moped (2.0.7)
91
- bson (~> 3.0)
92
- connection_pool (~> 2.0)
93
- optionable (~> 0.2.0)
94
- nokogiri (1.6.7.2)
95
- mini_portile2 (~> 2.0.0.rc2)
96
- optionable (0.2.0)
97
- origin (2.2.0)
91
+ nokogiri (1.7.0.1)
92
+ mini_portile2 (~> 2.1.0)
93
+ origin (2.3.0)
98
94
  orm_adapter (0.5.0)
99
- pry (0.10.3)
95
+ pry (0.10.4)
100
96
  coderay (~> 1.1.0)
101
97
  method_source (~> 0.8.1)
102
98
  slop (~> 3.4)
103
- rack (1.6.4)
99
+ rack (1.6.5)
104
100
  rack-test (0.6.3)
105
101
  rack (>= 1.0)
106
102
  rails-deprecated_sanitizer (1.0.3)
107
103
  activesupport (>= 4.2.0.alpha)
108
- rails-dom-testing (1.0.7)
104
+ rails-dom-testing (1.0.8)
109
105
  activesupport (>= 4.2.0.beta, < 5.0)
110
- nokogiri (~> 1.6.0)
106
+ nokogiri (~> 1.6)
111
107
  rails-deprecated_sanitizer (>= 1.0.1)
112
108
  rails-html-sanitizer (1.0.3)
113
109
  loofah (~> 2.0)
114
- railties (4.2.6)
115
- actionpack (= 4.2.6)
116
- activesupport (= 4.2.6)
110
+ railties (4.2.7.1)
111
+ actionpack (= 4.2.7.1)
112
+ activesupport (= 4.2.7.1)
117
113
  rake (>= 0.8.7)
118
114
  thor (>= 0.18.1, < 2.0)
119
- rake (11.2.2)
120
- responders (2.1.2)
115
+ rake (12.0.0)
116
+ responders (2.3.0)
121
117
  railties (>= 4.2.0, < 5.1)
122
118
  rspec (3.5.0)
123
119
  rspec-core (~> 3.5.0)
124
120
  rspec-expectations (~> 3.5.0)
125
121
  rspec-mocks (~> 3.5.0)
126
- rspec-core (3.5.0)
122
+ rspec-core (3.5.4)
127
123
  rspec-support (~> 3.5.0)
128
124
  rspec-expectations (3.5.0)
129
125
  diff-lcs (>= 1.2.0, < 2.0)
@@ -134,11 +130,11 @@ GEM
134
130
  rspec-support (3.5.0)
135
131
  slop (3.6.0)
136
132
  sparkr (0.4.1)
137
- term-ansicolor (1.3.2)
133
+ term-ansicolor (1.4.0)
138
134
  tins (~> 1.0)
139
- thor (0.19.1)
135
+ thor (0.19.4)
140
136
  thread_safe (0.3.5)
141
- tins (1.10.2)
137
+ tins (1.13.0)
142
138
  tzinfo (1.2.2)
143
139
  thread_safe (~> 0.1)
144
140
  warden (1.2.6)
@@ -160,4 +156,4 @@ DEPENDENCIES
160
156
  simple_token_authentication!
161
157
 
162
158
  BUNDLED WITH
163
- 1.11.2
159
+ 1.13.6
@@ -2,6 +2,4 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "mongoid", :git => "https://github.com/mongodb/mongoid.git", :branch => "master"
6
-
7
5
  gemspec :path => "../"
@@ -1,16 +1,7 @@
1
- GIT
2
- remote: https://github.com/mongodb/mongoid.git
3
- revision: f539cc6acd284bc87b64f6f043f74897d72387ad
4
- branch: master
5
- specs:
6
- mongoid (6.0.0)
7
- activemodel (~> 5.0)
8
- mongo (~> 2.2)
9
-
10
1
  PATH
11
2
  remote: ../
12
3
  specs:
13
- simple_token_authentication (1.14.0)
4
+ simple_token_authentication (1.15.0)
14
5
  actionmailer (>= 3.2.6, < 6)
15
6
  actionpack (>= 3.2.6, < 6)
16
7
  devise (>= 3.2, < 6)
@@ -18,35 +9,35 @@ PATH
18
9
  GEM
19
10
  remote: https://rubygems.org/
20
11
  specs:
21
- actionmailer (5.0.0)
22
- actionpack (= 5.0.0)
23
- actionview (= 5.0.0)
24
- activejob (= 5.0.0)
12
+ actionmailer (5.0.1)
13
+ actionpack (= 5.0.1)
14
+ actionview (= 5.0.1)
15
+ activejob (= 5.0.1)
25
16
  mail (~> 2.5, >= 2.5.4)
26
17
  rails-dom-testing (~> 2.0)
27
- actionpack (5.0.0)
28
- actionview (= 5.0.0)
29
- activesupport (= 5.0.0)
18
+ actionpack (5.0.1)
19
+ actionview (= 5.0.1)
20
+ activesupport (= 5.0.1)
30
21
  rack (~> 2.0)
31
22
  rack-test (~> 0.6.3)
32
23
  rails-dom-testing (~> 2.0)
33
24
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
34
- actionview (5.0.0)
35
- activesupport (= 5.0.0)
25
+ actionview (5.0.1)
26
+ activesupport (= 5.0.1)
36
27
  builder (~> 3.1)
37
28
  erubis (~> 2.7.0)
38
29
  rails-dom-testing (~> 2.0)
39
30
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
40
- activejob (5.0.0)
41
- activesupport (= 5.0.0)
31
+ activejob (5.0.1)
32
+ activesupport (= 5.0.1)
42
33
  globalid (>= 0.3.6)
43
- activemodel (5.0.0)
44
- activesupport (= 5.0.0)
45
- activerecord (5.0.0)
46
- activemodel (= 5.0.0)
47
- activesupport (= 5.0.0)
34
+ activemodel (5.0.1)
35
+ activesupport (= 5.0.1)
36
+ activerecord (5.0.1)
37
+ activemodel (= 5.0.1)
38
+ activesupport (= 5.0.1)
48
39
  arel (~> 7.0)
49
- activesupport (5.0.0)
40
+ activesupport (5.0.1)
50
41
  concurrent-ruby (~> 1.0, >= 1.0.2)
51
42
  i18n (~> 0.7)
52
43
  minitest (~> 5.1)
@@ -55,12 +46,12 @@ GEM
55
46
  bundler
56
47
  rake
57
48
  thor (>= 0.14.0)
58
- arel (7.0.0)
49
+ arel (7.1.4)
59
50
  bcrypt (3.1.11)
60
- bson (4.1.1)
61
- builder (3.2.2)
51
+ bson (4.2.1)
52
+ builder (3.2.3)
62
53
  coderay (1.1.1)
63
- concurrent-ruby (1.0.2)
54
+ concurrent-ruby (1.0.4)
64
55
  devise (4.2.0)
65
56
  bcrypt (~> 3.0)
66
57
  orm_adapter (~> 0.1)
@@ -69,7 +60,7 @@ GEM
69
60
  warden (~> 1.2.3)
70
61
  diff-lcs (1.2.5)
71
62
  erubis (2.7.0)
72
- globalid (0.3.6)
63
+ globalid (0.3.7)
73
64
  activesupport (>= 4.1.0)
74
65
  i18n (0.7.0)
75
66
  inch (0.7.1)
@@ -86,40 +77,41 @@ GEM
86
77
  mime-types-data (~> 3.2015)
87
78
  mime-types-data (3.2016.0521)
88
79
  mini_portile2 (2.1.0)
89
- minitest (5.9.0)
90
- mongo (2.2.5)
91
- bson (~> 4.0)
92
- nokogiri (1.6.8)
80
+ minitest (5.10.1)
81
+ mongo (2.4.1)
82
+ bson (>= 4.2.1, < 5.0.0)
83
+ mongoid (6.0.3)
84
+ activemodel (~> 5.0)
85
+ mongo (~> 2.3)
86
+ nokogiri (1.7.0.1)
93
87
  mini_portile2 (~> 2.1.0)
94
- pkg-config (~> 1.1.7)
95
88
  orm_adapter (0.5.0)
96
- pkg-config (1.1.7)
97
- pry (0.10.3)
89
+ pry (0.10.4)
98
90
  coderay (~> 1.1.0)
99
91
  method_source (~> 0.8.1)
100
92
  slop (~> 3.4)
101
93
  rack (2.0.1)
102
94
  rack-test (0.6.3)
103
95
  rack (>= 1.0)
104
- rails-dom-testing (2.0.1)
96
+ rails-dom-testing (2.0.2)
105
97
  activesupport (>= 4.2.0, < 6.0)
106
- nokogiri (~> 1.6.0)
98
+ nokogiri (~> 1.6)
107
99
  rails-html-sanitizer (1.0.3)
108
100
  loofah (~> 2.0)
109
- railties (5.0.0)
110
- actionpack (= 5.0.0)
111
- activesupport (= 5.0.0)
101
+ railties (5.0.1)
102
+ actionpack (= 5.0.1)
103
+ activesupport (= 5.0.1)
112
104
  method_source
113
105
  rake (>= 0.8.7)
114
106
  thor (>= 0.18.1, < 2.0)
115
- rake (11.2.2)
116
- responders (2.2.0)
107
+ rake (12.0.0)
108
+ responders (2.3.0)
117
109
  railties (>= 4.2.0, < 5.1)
118
110
  rspec (3.5.0)
119
111
  rspec-core (~> 3.5.0)
120
112
  rspec-expectations (~> 3.5.0)
121
113
  rspec-mocks (~> 3.5.0)
122
- rspec-core (3.5.1)
114
+ rspec-core (3.5.4)
123
115
  rspec-support (~> 3.5.0)
124
116
  rspec-expectations (3.5.0)
125
117
  diff-lcs (>= 1.2.0, < 2.0)
@@ -130,11 +122,11 @@ GEM
130
122
  rspec-support (3.5.0)
131
123
  slop (3.6.0)
132
124
  sparkr (0.4.1)
133
- term-ansicolor (1.3.2)
125
+ term-ansicolor (1.4.0)
134
126
  tins (~> 1.0)
135
- thor (0.19.1)
127
+ thor (0.19.4)
136
128
  thread_safe (0.3.5)
137
- tins (1.10.2)
129
+ tins (1.13.0)
138
130
  tzinfo (1.2.2)
139
131
  thread_safe (~> 0.1)
140
132
  warden (1.2.6)
@@ -148,9 +140,9 @@ DEPENDENCIES
148
140
  activerecord (>= 3.2.6, < 6)
149
141
  appraisal (~> 2.0)
150
142
  inch (~> 0.4)
151
- mongoid!
143
+ mongoid (>= 3.1.0, < 7)
152
144
  rspec (~> 3.0)
153
145
  simple_token_authentication!
154
146
 
155
147
  BUNDLED WITH
156
- 1.11.2
148
+ 1.13.6
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "actionmailer", ">= 3.2.6", "< 4"
6
6
  gem "actionpack", ">= 3.2.6", "< 4"
7
- gem "activerecord", ">= 3.2.6", "< 4"
7
+ gem "activerecord", ">= 3.2.15", "< 4"
8
8
  gem "mime-types", "< 3"
9
+ gem "term-ansicolor", "~> 1.3.0"
9
10
  gem "tins", "< 1.7.0"
10
11
 
11
12
  gemspec :path => "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- simple_token_authentication (1.14.0)
4
+ simple_token_authentication (1.15.0)
5
5
  actionmailer (>= 3.2.6, < 6)
6
6
  actionpack (>= 3.2.6, < 6)
7
7
  devise (>= 3.2, < 6)
@@ -9,12 +9,12 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionmailer (3.2.22.2)
13
- actionpack (= 3.2.22.2)
12
+ actionmailer (3.2.22.5)
13
+ actionpack (= 3.2.22.5)
14
14
  mail (~> 2.5.4)
15
- actionpack (3.2.22.2)
16
- activemodel (= 3.2.22.2)
17
- activesupport (= 3.2.22.2)
15
+ actionpack (3.2.22.5)
16
+ activemodel (= 3.2.22.5)
17
+ activesupport (= 3.2.22.5)
18
18
  builder (~> 3.0.0)
19
19
  erubis (~> 2.7.0)
20
20
  journey (~> 1.0.4)
@@ -22,15 +22,15 @@ GEM
22
22
  rack-cache (~> 1.2)
23
23
  rack-test (~> 0.6.1)
24
24
  sprockets (~> 2.2.1)
25
- activemodel (3.2.22.2)
26
- activesupport (= 3.2.22.2)
25
+ activemodel (3.2.22.5)
26
+ activesupport (= 3.2.22.5)
27
27
  builder (~> 3.0.0)
28
- activerecord (3.2.22.2)
29
- activemodel (= 3.2.22.2)
30
- activesupport (= 3.2.22.2)
28
+ activerecord (3.2.22.5)
29
+ activemodel (= 3.2.22.5)
30
+ activesupport (= 3.2.22.5)
31
31
  arel (~> 3.0.2)
32
32
  tzinfo (~> 0.3.29)
33
- activesupport (3.2.22.2)
33
+ activesupport (3.2.22.5)
34
34
  i18n (~> 0.6, >= 0.6.4)
35
35
  multi_json (~> 1.0)
36
36
  appraisal (2.1.0)
@@ -58,7 +58,7 @@ GEM
58
58
  term-ansicolor
59
59
  yard (~> 0.8.7.5)
60
60
  journey (1.0.4)
61
- json (1.8.3)
61
+ json (1.8.6)
62
62
  mail (2.5.4)
63
63
  mime-types (~> 1.16)
64
64
  treetop (~> 1.4.8)
@@ -74,7 +74,7 @@ GEM
74
74
  origin (1.1.0)
75
75
  orm_adapter (0.5.0)
76
76
  polyglot (0.3.5)
77
- pry (0.10.3)
77
+ pry (0.10.4)
78
78
  coderay (~> 1.1.0)
79
79
  method_source (~> 0.8.1)
80
80
  slop (~> 3.4)
@@ -85,14 +85,14 @@ GEM
85
85
  rack
86
86
  rack-test (0.6.3)
87
87
  rack (>= 1.0)
88
- railties (3.2.22.2)
89
- actionpack (= 3.2.22.2)
90
- activesupport (= 3.2.22.2)
88
+ railties (3.2.22.5)
89
+ actionpack (= 3.2.22.5)
90
+ activesupport (= 3.2.22.5)
91
91
  rack-ssl (~> 1.3.2)
92
92
  rake (>= 0.8.7)
93
93
  rdoc (~> 3.4)
94
94
  thor (>= 0.14.6, < 2.0)
95
- rake (11.2.2)
95
+ rake (12.0.0)
96
96
  rdoc (3.12.2)
97
97
  json (~> 1.4)
98
98
  responders (1.1.2)
@@ -101,7 +101,7 @@ GEM
101
101
  rspec-core (~> 3.5.0)
102
102
  rspec-expectations (~> 3.5.0)
103
103
  rspec-mocks (~> 3.5.0)
104
- rspec-core (3.5.0)
104
+ rspec-core (3.5.4)
105
105
  rspec-support (~> 3.5.0)
106
106
  rspec-expectations (3.5.0)
107
107
  diff-lcs (>= 1.2.0, < 2.0)
@@ -119,14 +119,14 @@ GEM
119
119
  tilt (~> 1.1, != 1.3.0)
120
120
  term-ansicolor (1.3.2)
121
121
  tins (~> 1.0)
122
- thor (0.19.1)
122
+ thor (0.19.4)
123
123
  thread_safe (0.3.5)
124
124
  tilt (1.4.1)
125
125
  tins (1.6.0)
126
126
  treetop (1.4.15)
127
127
  polyglot
128
128
  polyglot (>= 0.3.1)
129
- tzinfo (0.3.51)
129
+ tzinfo (0.3.52)
130
130
  warden (1.2.6)
131
131
  rack (>= 1.0)
132
132
  yard (0.8.7.6)
@@ -137,14 +137,15 @@ PLATFORMS
137
137
  DEPENDENCIES
138
138
  actionmailer (>= 3.2.6, < 4)
139
139
  actionpack (>= 3.2.6, < 4)
140
- activerecord (>= 3.2.6, < 4)
140
+ activerecord (>= 3.2.15, < 4)
141
141
  appraisal (~> 2.0)
142
142
  inch (~> 0.4)
143
143
  mime-types (< 3)
144
144
  mongoid (>= 3.1.0, < 7)
145
145
  rspec (~> 3.0)
146
146
  simple_token_authentication!
147
+ term-ansicolor (~> 1.3.0)
147
148
  tins (< 1.7.0)
148
149
 
149
150
  BUNDLED WITH
150
- 1.11.2
151
+ 1.13.6
@@ -27,11 +27,20 @@ module SimpleTokenAuthentication
27
27
  private :integrate_with_devise_case_insensitive_keys
28
28
  end
29
29
 
30
+ # This method is a hook and is meant to be overridden.
31
+ #
32
+ # It is not expected to return anything special,
33
+ # only its side effects will be used.
34
+ def after_successful_token_authentication
35
+ # intentionally left blank
36
+ end
37
+
30
38
  def authenticate_entity_from_token!(entity)
31
39
  record = find_record_from_identifier(entity)
32
40
 
33
41
  if token_correct?(record, entity, token_comparator)
34
42
  perform_sign_in!(record, sign_in_handler)
43
+ after_successful_token_authentication
35
44
  end
36
45
  end
37
46
 
@@ -1,3 +1,3 @@
1
1
  module SimpleTokenAuthentication
2
- VERSION = "1.14.0"
2
+ VERSION = "1.15.0".freeze
3
3
  end
@@ -691,4 +691,32 @@ describe 'Any class which includes SimpleTokenAuthentication::TokenAuthenticatio
691
691
  end
692
692
  end
693
693
  end
694
+
695
+ describe '#authenticate_entity_from_token!' do
696
+
697
+ let(:token_authentication_handler) { described_class.new }
698
+
699
+ before(:each) do
700
+ allow(token_authentication_handler).to receive(:find_record_from_identifier)
701
+ allow(token_authentication_handler).to receive(:perform_sign_in!)
702
+ allow(token_authentication_handler).to receive(:token_correct?).and_return(false)
703
+ end
704
+
705
+ it 'does not trigger the :after_successful_token_authentication hook', hooks: true, private: true do
706
+ expect(token_authentication_handler).not_to receive(:after_successful_token_authentication)
707
+ token_authentication_handler.send(:authenticate_entity_from_token!, double)
708
+ end
709
+
710
+ context 'after successful authentication' do
711
+
712
+ before(:each) do
713
+ allow(token_authentication_handler).to receive(:token_correct?).and_return(true)
714
+ end
715
+
716
+ it 'calls the :after_successful_token_authentication hook', hooks: true, protected: true do
717
+ expect(token_authentication_handler).to receive(:after_successful_token_authentication).once
718
+ token_authentication_handler.send(:authenticate_entity_from_token!, double)
719
+ end
720
+ end
721
+ end
694
722
  end
@@ -5,4 +5,11 @@ RSpec.shared_examples 'a token authentication handler' do
5
5
  it 'responds to :handle_token_authentication_for', private: true do
6
6
  expect(token_authentication_handler).to respond_to :handle_token_authentication_for
7
7
  end
8
+
9
+ describe 'instance' do
10
+
11
+ it 'responds to :after_successful_token_authentication', hooks: true, private: true do
12
+ expect(token_authentication_handler.new).to respond_to :after_successful_token_authentication
13
+ end
14
+ end
8
15
  end
metadata CHANGED
@@ -1,155 +1,155 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_token_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Bulnes Guilpain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-09 00:00:00.000000000 Z
11
+ date: 2017-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.6
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '6'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ! '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.6
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '6'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: actionpack
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ! '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 3.2.6
40
- - - <
40
+ - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '6'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ! '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: 3.2.6
50
- - - <
50
+ - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '6'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: devise
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ! '>='
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '3.2'
60
- - - <
60
+ - - "<"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '6'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ! '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '3.2'
70
- - - <
70
+ - - "<"
71
71
  - !ruby/object:Gem::Version
72
72
  version: '6'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: rspec
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ~>
77
+ - - "~>"
78
78
  - !ruby/object:Gem::Version
79
79
  version: '3.0'
80
80
  type: :development
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - ~>
84
+ - - "~>"
85
85
  - !ruby/object:Gem::Version
86
86
  version: '3.0'
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: inch
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - ~>
91
+ - - "~>"
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0.4'
94
94
  type: :development
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - ~>
98
+ - - "~>"
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0.4'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: activerecord
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - ! '>='
105
+ - - ">="
106
106
  - !ruby/object:Gem::Version
107
107
  version: 3.2.6
108
- - - <
108
+ - - "<"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '6'
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: 3.2.6
118
- - - <
118
+ - - "<"
119
119
  - !ruby/object:Gem::Version
120
120
  version: '6'
121
121
  - !ruby/object:Gem::Dependency
122
122
  name: mongoid
123
123
  requirement: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - ! '>='
125
+ - - ">="
126
126
  - !ruby/object:Gem::Version
127
127
  version: 3.1.0
128
- - - <
128
+ - - "<"
129
129
  - !ruby/object:Gem::Version
130
130
  version: '7'
131
131
  type: :development
132
132
  prerelease: false
133
133
  version_requirements: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - ! '>='
135
+ - - ">="
136
136
  - !ruby/object:Gem::Version
137
137
  version: 3.1.0
138
- - - <
138
+ - - "<"
139
139
  - !ruby/object:Gem::Version
140
140
  version: '7'
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: appraisal
143
143
  requirement: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ~>
145
+ - - "~>"
146
146
  - !ruby/object:Gem::Version
147
147
  version: '2.0'
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ~>
152
+ - - "~>"
153
153
  - !ruby/object:Gem::Version
154
154
  version: '2.0'
155
155
  description:
@@ -167,7 +167,6 @@ files:
167
167
  - doc/README.md
168
168
  - gemfiles/rails_4_devise_3.gemfile
169
169
  - gemfiles/rails_4_devise_3.gemfile.lock
170
- - gemfiles/rails_4_devise_4.gemfile.lock
171
170
  - gemfiles/rails_5_devise_4.gemfile
172
171
  - gemfiles/rails_5_devise_4.gemfile.lock
173
172
  - gemfiles/ruby_1.9.3_rails_3.2.gemfile
@@ -237,17 +236,17 @@ require_paths:
237
236
  - lib
238
237
  required_ruby_version: !ruby/object:Gem::Requirement
239
238
  requirements:
240
- - - ! '>='
239
+ - - ">="
241
240
  - !ruby/object:Gem::Version
242
241
  version: '0'
243
242
  required_rubygems_version: !ruby/object:Gem::Requirement
244
243
  requirements:
245
- - - ! '>='
244
+ - - ">="
246
245
  - !ruby/object:Gem::Version
247
246
  version: '0'
248
247
  requirements: []
249
248
  rubyforge_project:
250
- rubygems_version: 2.6.6
249
+ rubygems_version: 2.6.1
251
250
  signing_key:
252
251
  specification_version: 4
253
252
  summary: Simple (but safe) token authentication for Rails apps or API with Devise.
@@ -291,7 +290,7 @@ test_files:
291
290
  - gemfiles/rails_5_devise_4.gemfile
292
291
  - gemfiles/ruby_1.9.3_rails_3.2.gemfile
293
292
  - gemfiles/rails_4_devise_3.gemfile.lock
294
- - gemfiles/rails_4_devise_4.gemfile.lock
295
293
  - gemfiles/rails_5_devise_4.gemfile.lock
296
294
  - gemfiles/ruby_1.9.3_rails_3.2.gemfile.lock
297
295
  - Appraisals
296
+ has_rdoc:
@@ -1,159 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- simple_token_authentication (1.13.0)
5
- actionmailer (>= 3.2.6, < 5)
6
- actionpack (>= 3.2.6, < 5)
7
- devise (>= 3.2, < 5)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- actionmailer (4.2.6)
13
- actionpack (= 4.2.6)
14
- actionview (= 4.2.6)
15
- activejob (= 4.2.6)
16
- mail (~> 2.5, >= 2.5.4)
17
- rails-dom-testing (~> 1.0, >= 1.0.5)
18
- actionpack (4.2.6)
19
- actionview (= 4.2.6)
20
- activesupport (= 4.2.6)
21
- rack (~> 1.6)
22
- rack-test (~> 0.6.2)
23
- rails-dom-testing (~> 1.0, >= 1.0.5)
24
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
25
- actionview (4.2.6)
26
- activesupport (= 4.2.6)
27
- builder (~> 3.1)
28
- erubis (~> 2.7.0)
29
- rails-dom-testing (~> 1.0, >= 1.0.5)
30
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
31
- activejob (4.2.6)
32
- activesupport (= 4.2.6)
33
- globalid (>= 0.3.0)
34
- activemodel (4.2.6)
35
- activesupport (= 4.2.6)
36
- builder (~> 3.1)
37
- activerecord (4.2.6)
38
- activemodel (= 4.2.6)
39
- activesupport (= 4.2.6)
40
- arel (~> 6.0)
41
- activesupport (4.2.6)
42
- i18n (~> 0.7)
43
- json (~> 1.7, >= 1.7.7)
44
- minitest (~> 5.1)
45
- thread_safe (~> 0.3, >= 0.3.4)
46
- tzinfo (~> 1.1)
47
- appraisal (2.1.0)
48
- bundler
49
- rake
50
- thor (>= 0.14.0)
51
- arel (6.0.3)
52
- bcrypt (3.1.11)
53
- bson (3.2.6)
54
- builder (3.2.2)
55
- coderay (1.1.1)
56
- connection_pool (2.2.0)
57
- devise (4.0.0)
58
- bcrypt (~> 3.0)
59
- orm_adapter (~> 0.1)
60
- railties (>= 4.1.0, < 5.1)
61
- responders
62
- warden (~> 1.2.3)
63
- diff-lcs (1.2.5)
64
- erubis (2.7.0)
65
- globalid (0.3.6)
66
- activesupport (>= 4.1.0)
67
- i18n (0.7.0)
68
- inch (0.7.1)
69
- pry
70
- sparkr (>= 0.2.0)
71
- term-ansicolor
72
- yard (~> 0.8.7.5)
73
- json (1.8.3)
74
- loofah (2.0.3)
75
- nokogiri (>= 1.5.9)
76
- mail (2.6.4)
77
- mime-types (>= 1.16, < 4)
78
- method_source (0.8.2)
79
- mime-types (3.1)
80
- mime-types-data (~> 3.2015)
81
- mime-types-data (3.2016.0521)
82
- mini_portile2 (2.0.0)
83
- minitest (5.9.0)
84
- mongoid (4.0.2)
85
- activemodel (~> 4.0)
86
- moped (~> 2.0.0)
87
- origin (~> 2.1)
88
- tzinfo (>= 0.3.37)
89
- moped (2.0.7)
90
- bson (~> 3.0)
91
- connection_pool (~> 2.0)
92
- optionable (~> 0.2.0)
93
- nokogiri (1.6.7.2)
94
- mini_portile2 (~> 2.0.0.rc2)
95
- optionable (0.2.0)
96
- origin (2.2.0)
97
- orm_adapter (0.5.0)
98
- pry (0.10.3)
99
- coderay (~> 1.1.0)
100
- method_source (~> 0.8.1)
101
- slop (~> 3.4)
102
- rack (1.6.4)
103
- rack-test (0.6.3)
104
- rack (>= 1.0)
105
- rails-deprecated_sanitizer (1.0.3)
106
- activesupport (>= 4.2.0.alpha)
107
- rails-dom-testing (1.0.7)
108
- activesupport (>= 4.2.0.beta, < 5.0)
109
- nokogiri (~> 1.6.0)
110
- rails-deprecated_sanitizer (>= 1.0.1)
111
- rails-html-sanitizer (1.0.3)
112
- loofah (~> 2.0)
113
- railties (4.2.6)
114
- actionpack (= 4.2.6)
115
- activesupport (= 4.2.6)
116
- rake (>= 0.8.7)
117
- thor (>= 0.18.1, < 2.0)
118
- rake (11.2.2)
119
- responders (2.1.2)
120
- railties (>= 4.2.0, < 5.1)
121
- rspec (3.5.0)
122
- rspec-core (~> 3.5.0)
123
- rspec-expectations (~> 3.5.0)
124
- rspec-mocks (~> 3.5.0)
125
- rspec-core (3.5.0)
126
- rspec-support (~> 3.5.0)
127
- rspec-expectations (3.5.0)
128
- diff-lcs (>= 1.2.0, < 2.0)
129
- rspec-support (~> 3.5.0)
130
- rspec-mocks (3.5.0)
131
- diff-lcs (>= 1.2.0, < 2.0)
132
- rspec-support (~> 3.5.0)
133
- rspec-support (3.5.0)
134
- slop (3.6.0)
135
- sparkr (0.4.1)
136
- term-ansicolor (1.3.2)
137
- tins (~> 1.0)
138
- thor (0.19.1)
139
- thread_safe (0.3.5)
140
- tins (1.10.2)
141
- tzinfo (1.2.2)
142
- thread_safe (~> 0.1)
143
- warden (1.2.6)
144
- rack (>= 1.0)
145
- yard (0.8.7.6)
146
-
147
- PLATFORMS
148
- ruby
149
-
150
- DEPENDENCIES
151
- activerecord (>= 3.2.6, < 5)
152
- appraisal (~> 2.0)
153
- inch (~> 0.4)
154
- mongoid (>= 3.1.0, < 5)
155
- rspec (~> 3.0)
156
- simple_token_authentication!
157
-
158
- BUNDLED WITH
159
- 1.11.2