simple_token_authentication 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/simple_token_authentication/adapters/rails_metal_adapter.rb +14 -0
- data/lib/simple_token_authentication/configuration.rb +3 -2
- data/lib/simple_token_authentication/version.rb +1 -1
- data/spec/lib/simple_token_authentication/adapters/rails_metal_adapter_spec.rb +21 -0
- data/spec/lib/simple_token_authentication/configuration_spec.rb +3 -2
- data/spec/lib/simple_token_authentication_spec.rb +37 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b03d7c4181d9b49529232f123b1808777ae5ec90
|
4
|
+
data.tar.gz: 4353f4f11e3460fdcff2fcb347493a4f99aad30d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa498468bc95566d8ca4617a224c46cff942c8a3b5aa1c017491ccf8acf2559b5658b4f1ca1b3ce0103c08078aa1cf7284f3f79f693e6c2b63753bc7f7688d38
|
7
|
+
data.tar.gz: d5daa1bd3f516d6be6fe97c78d9898f24c7ec6f22558d3c908db3690ef0e15be4c444ee990f0b14288849e0fd4ab780b5375db56844b897c24edf22ffd5841c9
|
data/README.md
CHANGED
@@ -95,6 +95,7 @@ Finally define which controllers will handle token authentication (typ. `Applica
|
|
95
95
|
# app/controllers/application_controller.rb
|
96
96
|
|
97
97
|
class ApplicationController < ActionController::Base # or ActionController::API
|
98
|
+
# or ActionController::Metal
|
98
99
|
# ...
|
99
100
|
|
100
101
|
acts_as_token_authentication_handler_for User
|
@@ -330,7 +331,7 @@ License
|
|
330
331
|
-------
|
331
332
|
|
332
333
|
Simple Token Authentication
|
333
|
-
Copyright (C) 2013, 2014, 2015 Gonzalo Bulnes Guilpain
|
334
|
+
Copyright (C) 2013, 2014, 2015, 2016 Gonzalo Bulnes Guilpain
|
334
335
|
|
335
336
|
This program is free software: you can redistribute it and/or modify
|
336
337
|
it under the terms of the GNU General Public License as published by
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'action_controller'
|
2
|
+
require 'simple_token_authentication/adapter'
|
3
|
+
|
4
|
+
module SimpleTokenAuthentication
|
5
|
+
module Adapters
|
6
|
+
class RailsMetalAdapter
|
7
|
+
extend SimpleTokenAuthentication::Adapter
|
8
|
+
|
9
|
+
def self.base_class
|
10
|
+
::ActionController::Metal
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -15,12 +15,13 @@ module SimpleTokenAuthentication
|
|
15
15
|
@@header_names = {}
|
16
16
|
@@identifiers = {}
|
17
17
|
@@sign_in_token = false
|
18
|
-
@@controller_adapters = ['rails', 'rails_api']
|
18
|
+
@@controller_adapters = ['rails', 'rails_api', 'rails_metal']
|
19
19
|
@@model_adapters = ['active_record', 'mongoid']
|
20
20
|
@@adapters_dependencies = { 'active_record' => 'ActiveRecord::Base',
|
21
21
|
'mongoid' => 'Mongoid::Document',
|
22
22
|
'rails' => 'ActionController::Base',
|
23
|
-
'rails_api' => 'ActionController::API'
|
23
|
+
'rails_api' => 'ActionController::API',
|
24
|
+
'rails_metal' => 'ActionController::Metal' }
|
24
25
|
@@skip_devise_trackable = true
|
25
26
|
|
26
27
|
# Allow the default configuration to be overwritten from initializers
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'simple_token_authentication/adapters/rails_metal_adapter'
|
3
|
+
|
4
|
+
describe 'SimpleTokenAuthentication::Adapters::RailsMetalAdapter' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
stub_const('ActionController', Module.new)
|
8
|
+
stub_const('ActionController::Metal', double())
|
9
|
+
|
10
|
+
@subject = SimpleTokenAuthentication::Adapters::RailsMetalAdapter
|
11
|
+
end
|
12
|
+
|
13
|
+
it_behaves_like 'an adapter'
|
14
|
+
|
15
|
+
describe '.base_class' do
|
16
|
+
|
17
|
+
it 'is ActionController::Metal', private: true do
|
18
|
+
expect(@subject.base_class).to eq ActionController::Metal
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -20,8 +20,8 @@ describe SimpleTokenAuthentication::Configuration do
|
|
20
20
|
|
21
21
|
it_behaves_like 'a configuration option', 'controller_adapters'
|
22
22
|
|
23
|
-
it "defauts to ['rails', 'rails_api']", private: true do
|
24
|
-
expect(@subject.controller_adapters).to eq ['rails', 'rails_api']
|
23
|
+
it "defauts to ['rails', 'rails_api', 'rails_metal']", private: true do
|
24
|
+
expect(@subject.controller_adapters).to eq ['rails', 'rails_api', 'rails_metal']
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -43,6 +43,7 @@ describe SimpleTokenAuthentication::Configuration do
|
|
43
43
|
expect(@subject.adapters_dependencies['mongoid']).to eq 'Mongoid::Document'
|
44
44
|
expect(@subject.adapters_dependencies['rails']).to eq 'ActionController::Base'
|
45
45
|
expect(@subject.adapters_dependencies['rails_api']).to eq 'ActionController::API'
|
46
|
+
expect(@subject.adapters_dependencies['rails_metal']).to eq 'ActionController::Metal'
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
@@ -178,4 +178,41 @@ describe SimpleTokenAuthentication do
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
end
|
181
|
+
|
182
|
+
context "when ActionController::Metal is available" do
|
183
|
+
|
184
|
+
before(:each) do
|
185
|
+
stub_const('ActionController::Metal', Class.new)
|
186
|
+
|
187
|
+
# define a dummy ActionController::Metal (a.k.a 'Rails Metal') adapter
|
188
|
+
dummy_rails_adapter = double()
|
189
|
+
allow(dummy_rails_adapter).to receive(:base_class).and_return(ActionController::Metal)
|
190
|
+
stub_const('SimpleTokenAuthentication::Adapters::DummyRailsMetalAdapter', dummy_rails_adapter)
|
191
|
+
end
|
192
|
+
|
193
|
+
describe '#ensure_controllers_can_act_as_token_authentication_handlers' do
|
194
|
+
|
195
|
+
before(:each) do
|
196
|
+
class SimpleTokenAuthentication::DummyController < ActionController::Metal; end
|
197
|
+
@dummy_controller = SimpleTokenAuthentication::DummyController
|
198
|
+
|
199
|
+
expect(@dummy_controller.new).to be_instance_of SimpleTokenAuthentication::DummyController
|
200
|
+
expect(@dummy_controller.new).to be_kind_of ActionController::Metal
|
201
|
+
end
|
202
|
+
|
203
|
+
after(:each) do
|
204
|
+
SimpleTokenAuthentication.send(:remove_const, :DummyController)
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'allows any kind of ActionController::Metal to acts as token authentication handler', private: true do
|
208
|
+
expect(@dummy_controller).not_to respond_to :acts_as_token_authentication_handler_for
|
209
|
+
|
210
|
+
subject.ensure_controllers_can_act_as_token_authentication_handlers [
|
211
|
+
SimpleTokenAuthentication::Adapters::DummyRailsMetalAdapter]
|
212
|
+
|
213
|
+
expect(@dummy_controller).to respond_to :acts_as_token_authentication_handler_for
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
181
218
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_token_authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.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:
|
11
|
+
date: 2016-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- lib/simple_token_authentication/adapters/mongoid_adapter.rb
|
166
166
|
- lib/simple_token_authentication/adapters/rails_adapter.rb
|
167
167
|
- lib/simple_token_authentication/adapters/rails_api_adapter.rb
|
168
|
+
- lib/simple_token_authentication/adapters/rails_metal_adapter.rb
|
168
169
|
- lib/simple_token_authentication/configuration.rb
|
169
170
|
- lib/simple_token_authentication/devise_fallback_handler.rb
|
170
171
|
- lib/simple_token_authentication/entities_manager.rb
|
@@ -188,6 +189,7 @@ files:
|
|
188
189
|
- spec/lib/simple_token_authentication/adapters/mongoid_adapter_spec.rb
|
189
190
|
- spec/lib/simple_token_authentication/adapters/rails_adapter_spec.rb
|
190
191
|
- spec/lib/simple_token_authentication/adapters/rails_api_adapter_spec.rb
|
192
|
+
- spec/lib/simple_token_authentication/adapters/rails_metal_adapter_spec.rb
|
191
193
|
- spec/lib/simple_token_authentication/configuration_spec.rb
|
192
194
|
- spec/lib/simple_token_authentication/devise_fallback_handler_spec.rb
|
193
195
|
- spec/lib/simple_token_authentication/entities_manager_spec.rb
|
@@ -261,6 +263,7 @@ test_files:
|
|
261
263
|
- spec/lib/simple_token_authentication/acts_as_token_authentication_handler_spec.rb
|
262
264
|
- spec/lib/simple_token_authentication/adapters/rails_api_adapter_spec.rb
|
263
265
|
- spec/lib/simple_token_authentication/adapters/rails_adapter_spec.rb
|
266
|
+
- spec/lib/simple_token_authentication/adapters/rails_metal_adapter_spec.rb
|
264
267
|
- spec/lib/simple_token_authentication/adapters/mongoid_adapter_spec.rb
|
265
268
|
- spec/lib/simple_token_authentication/adapters/active_record_adapter_spec.rb
|
266
269
|
- spec/lib/simple_token_authentication/errors_spec.rb
|