devise_ott 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a55342cc96a9ffaad894f0dee19bdaeb922d85ac
4
- data.tar.gz: d12e832a72eebbfcb841f8a5d664e985509ab0f2
3
+ metadata.gz: 8508276fc71bad33d69f02161674540030945e2f
4
+ data.tar.gz: fa4229d5e4aaf811ef8e0642ce0edad040b8a31a
5
5
  SHA512:
6
- metadata.gz: 4c24bbf7c7748cfdddd822939f5ab5ecec87dbc55dab84c5f95ca449a371406b7af58b198e66574330ba74c3ddb9b80f7cf6275e7e291e3102fa2ff41453ed1b
7
- data.tar.gz: 11dff1e86aa589c091e400497ccf198cae21afb4e75b6e498d6d2a4c442c340f4319228e168526e1c54865aa20d49fe40f394b551c30485bf7115d891d871e77
6
+ metadata.gz: 6dfdf0b6df1d047645528ad8143471e3e99de6237a9b9e8d44e311b38490b4ddaac4b1f1043923de7c18e35e7ab64834955d5e0c8879b791530ee30d354a840d
7
+ data.tar.gz: 597de8875e49b95be1c2a5137e916d7c3e94a25a622b112d45595968adb988813803be679e0c59b6333c81d93f0890c81d8d8e1fa93309281d8582a633088b3c
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.1.0
1
+ ruby-2.2.0
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.0.0
5
4
  - 2.1.0
5
+ - 2.2.0
6
6
  before_install:
7
- - gem install bundler -v '= 1.5.1'
7
+ - gem install bundler -v '= 1.7.11'
8
8
  services:
9
9
  - redis-server
data/Gemfile.lock CHANGED
@@ -1,114 +1,141 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devise_ott (0.0.2)
4
+ devise_ott (0.0.4)
5
5
  devise
6
6
  redis
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionmailer (4.0.2)
12
- actionpack (= 4.0.2)
13
- mail (~> 2.5.4)
14
- actionpack (4.0.2)
15
- activesupport (= 4.0.2)
16
- builder (~> 3.1.0)
17
- erubis (~> 2.7.0)
18
- rack (~> 1.5.2)
11
+ actionmailer (4.2.0)
12
+ actionpack (= 4.2.0)
13
+ actionview (= 4.2.0)
14
+ activejob (= 4.2.0)
15
+ mail (~> 2.5, >= 2.5.4)
16
+ rails-dom-testing (~> 1.0, >= 1.0.5)
17
+ actionpack (4.2.0)
18
+ actionview (= 4.2.0)
19
+ activesupport (= 4.2.0)
20
+ rack (~> 1.6.0)
19
21
  rack-test (~> 0.6.2)
20
- activemodel (4.0.2)
21
- activesupport (= 4.0.2)
22
- builder (~> 3.1.0)
23
- activerecord (4.0.2)
24
- activemodel (= 4.0.2)
25
- activerecord-deprecated_finders (~> 1.0.2)
26
- activesupport (= 4.0.2)
27
- arel (~> 4.0.0)
28
- activerecord-deprecated_finders (1.0.3)
29
- activesupport (4.0.2)
30
- i18n (~> 0.6, >= 0.6.4)
31
- minitest (~> 4.2)
32
- multi_json (~> 1.3)
33
- thread_safe (~> 0.1)
34
- tzinfo (~> 0.3.37)
35
- arel (4.0.1)
36
- atomic (1.1.14)
37
- bcrypt-ruby (3.1.2)
38
- builder (3.1.4)
39
- coveralls (0.7.0)
22
+ rails-dom-testing (~> 1.0, >= 1.0.5)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
24
+ actionview (4.2.0)
25
+ activesupport (= 4.2.0)
26
+ builder (~> 3.1)
27
+ erubis (~> 2.7.0)
28
+ rails-dom-testing (~> 1.0, >= 1.0.5)
29
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
30
+ activejob (4.2.0)
31
+ activesupport (= 4.2.0)
32
+ globalid (>= 0.3.0)
33
+ activemodel (4.2.0)
34
+ activesupport (= 4.2.0)
35
+ builder (~> 3.1)
36
+ activerecord (4.2.0)
37
+ activemodel (= 4.2.0)
38
+ activesupport (= 4.2.0)
39
+ arel (~> 6.0)
40
+ activesupport (4.2.0)
41
+ i18n (~> 0.7)
42
+ json (~> 1.7, >= 1.7.7)
43
+ minitest (~> 5.1)
44
+ thread_safe (~> 0.3, >= 0.3.4)
45
+ tzinfo (~> 1.1)
46
+ arel (6.0.0)
47
+ bcrypt (3.1.9)
48
+ builder (3.2.2)
49
+ coveralls (0.7.2)
40
50
  multi_json (~> 1.3)
41
- rest-client
51
+ rest-client (= 1.6.7)
42
52
  simplecov (>= 0.7)
43
- term-ansicolor
44
- thor
45
- devise (3.2.2)
46
- bcrypt-ruby (~> 3.0)
53
+ term-ansicolor (= 1.2.2)
54
+ thor (= 0.18.1)
55
+ devise (3.4.1)
56
+ bcrypt (~> 3.0)
47
57
  orm_adapter (~> 0.1)
48
58
  railties (>= 3.2.6, < 5)
59
+ responders
49
60
  thread_safe (~> 0.1)
50
61
  warden (~> 1.2.3)
51
- docile (1.1.1)
62
+ docile (1.1.5)
52
63
  erubis (2.7.0)
64
+ globalid (0.3.0)
65
+ activesupport (>= 4.1.0)
53
66
  hike (1.2.3)
54
- i18n (0.6.9)
55
- mail (2.5.4)
56
- mime-types (~> 1.16)
57
- treetop (~> 1.4.8)
58
- mime-types (1.25.1)
59
- minitest (4.7.5)
60
- minitest-rails (0.9.2)
61
- minitest (~> 4.7)
62
- rails (>= 3.0)
63
- multi_json (1.8.2)
67
+ i18n (0.7.0)
68
+ json (1.8.1)
69
+ loofah (2.0.1)
70
+ nokogiri (>= 1.5.9)
71
+ mail (2.6.3)
72
+ mime-types (>= 1.16, < 3)
73
+ mime-types (2.4.3)
74
+ mini_portile (0.6.2)
75
+ minitest (5.5.0)
76
+ minitest-rails (2.1.1)
77
+ minitest (~> 5.4)
78
+ railties (~> 4.1)
79
+ multi_json (1.10.1)
80
+ nokogiri (1.6.5)
81
+ mini_portile (~> 0.6.0)
64
82
  orm_adapter (0.5.0)
65
- polyglot (0.3.3)
66
- rack (1.5.2)
83
+ rack (1.6.0)
67
84
  rack-test (0.6.2)
68
85
  rack (>= 1.0)
69
- rails (4.0.2)
70
- actionmailer (= 4.0.2)
71
- actionpack (= 4.0.2)
72
- activerecord (= 4.0.2)
73
- activesupport (= 4.0.2)
86
+ rails (4.2.0)
87
+ actionmailer (= 4.2.0)
88
+ actionpack (= 4.2.0)
89
+ actionview (= 4.2.0)
90
+ activejob (= 4.2.0)
91
+ activemodel (= 4.2.0)
92
+ activerecord (= 4.2.0)
93
+ activesupport (= 4.2.0)
74
94
  bundler (>= 1.3.0, < 2.0)
75
- railties (= 4.0.2)
76
- sprockets-rails (~> 2.0.0)
77
- railties (4.0.2)
78
- actionpack (= 4.0.2)
79
- activesupport (= 4.0.2)
95
+ railties (= 4.2.0)
96
+ sprockets-rails
97
+ rails-deprecated_sanitizer (1.0.3)
98
+ activesupport (>= 4.2.0.alpha)
99
+ rails-dom-testing (1.0.5)
100
+ activesupport (>= 4.2.0.beta, < 5.0)
101
+ nokogiri (~> 1.6.0)
102
+ rails-deprecated_sanitizer (>= 1.0.1)
103
+ rails-html-sanitizer (1.0.1)
104
+ loofah (~> 2.0)
105
+ railties (4.2.0)
106
+ actionpack (= 4.2.0)
107
+ activesupport (= 4.2.0)
80
108
  rake (>= 0.8.7)
81
109
  thor (>= 0.18.1, < 2.0)
82
- rake (10.1.1)
83
- redis (3.0.6)
110
+ rake (10.4.2)
111
+ redis (3.2.0)
112
+ responders (2.0.2)
113
+ railties (>= 4.2.0.alpha, < 5)
84
114
  rest-client (1.6.7)
85
115
  mime-types (>= 1.16)
86
- simplecov (0.8.2)
116
+ simplecov (0.9.1)
87
117
  docile (~> 1.1.0)
88
- multi_json
118
+ multi_json (~> 1.0)
89
119
  simplecov-html (~> 0.8.0)
90
120
  simplecov-html (0.8.0)
91
- sprockets (2.10.1)
121
+ sprockets (2.12.3)
92
122
  hike (~> 1.2)
93
123
  multi_json (~> 1.0)
94
124
  rack (~> 1.0)
95
125
  tilt (~> 1.1, != 1.3.0)
96
- sprockets-rails (2.0.1)
126
+ sprockets-rails (2.2.2)
97
127
  actionpack (>= 3.0)
98
128
  activesupport (>= 3.0)
99
- sprockets (~> 2.8)
100
- sqlite3 (1.3.8)
129
+ sprockets (>= 2.8, < 4.0)
130
+ sqlite3 (1.3.10)
101
131
  term-ansicolor (1.2.2)
102
132
  tins (~> 0.8)
103
133
  thor (0.18.1)
104
- thread_safe (0.1.3)
105
- atomic
134
+ thread_safe (0.3.4)
106
135
  tilt (1.4.1)
107
- tins (0.13.1)
108
- treetop (1.4.15)
109
- polyglot
110
- polyglot (>= 0.3.1)
111
- tzinfo (0.3.38)
136
+ tins (0.13.2)
137
+ tzinfo (1.2.2)
138
+ thread_safe (~> 0.1)
112
139
  warden (1.2.3)
113
140
  rack (>= 1.0)
114
141
 
@@ -0,0 +1,21 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhpZ2Fn
3
+ bmlkejEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
+ MB4XDTE1MDEwODE5MzIwOFoXDTE2MDEwODE5MzIwOFowPzERMA8GA1UEAwwIaWdh
5
+ Z25pZHoxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
+ bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ0cv4cvT8KGKoE/GQkE
7
+ cmpazFdWcsFo3wB0ft2o+7Do3aEQr277pP/LS7rLmS2c9WB5Xc3cKmxBJ9KJISla
8
+ AwqMy+X7QPK1r/eSdX5vtEG9UzhKHoZ5OA/Vp0gndRpxx4irCDA6JCvoukMkqQ4C
9
+ nglrIZPFj7zl9JvcefT/LrgSdiwvoiuO8iqMiL51FlqwkUdfKrh4hPvMh3RWMj/p
10
+ GTGnUURf0M+2CqRAGZtdb/lb8Kd1Vv0Cnv4iD8fapBRbBHZPgvx3+bVAeRIZShJ8
11
+ WUcNn9pq+f33bdffP/uRgP7y/CxfsUBdw/8ah09GhN4LNKEqxidxf6hINmHjwPAT
12
+ glsCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFDmc
13
+ zYuJzjhQ/s5LMjqRzCHX30SSMB0GA1UdEQQWMBSBEmlnYWduaWR6QGdtYWlsLmNv
14
+ bTAdBgNVHRIEFjAUgRJpZ2FnbmlkekBnbWFpbC5jb20wDQYJKoZIhvcNAQEFBQAD
15
+ ggEBAEmZDywFynEyzEU+QBMGRi1eQOkqvuRClgsafPYSzBJJBjfdkPdBex0otrYw
16
+ nPBa0QJ16HOkQneP6+Yigdk8hRYJslCwd23U7Wp99pt3Y9GttWqz/Dxv+9vSMdk/
17
+ jXfPW2TKhIb4sLM4maZn9iBs8ZA3nWv2pE0qnwBEIl9G7Dv+D4qLt5nLZklTWwN6
18
+ A6qAwUctdSvdK5VuKmwOYHAWP513GniqD3xvniFibU9a8Af3KQ6IZQiRT5NWevpy
19
+ tjvVd764uFwJPlAjClP53jeL57tIcc7deTQGo60vZO7PGu2lXaA+fb+/XKvjIM8F
20
+ 36lNHFVYlpW6ipD6uwf6dHgmKsM=
21
+ -----END CERTIFICATE-----
data/devise_ott.gemspec CHANGED
@@ -18,6 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ # Dont sing yet.
22
+ # spec.cert_chain = ['certs/igagnidz.pem']
23
+ # spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $0 =~ /gem\z/
24
+
21
25
  spec.add_dependency 'devise'
22
26
  spec.add_dependency 'redis'
23
27
 
@@ -7,9 +7,6 @@ module DeviseOtt
7
7
 
8
8
  def authenticate!
9
9
  ott_token = params[:ott_token]
10
-
11
- return unless mapping.to.respond_to?(:find_for_ott_authentication) # Dont try to authenticate if module is not included
12
-
13
10
  resource = mapping.to.find_for_ott_authentication(ott_token)
14
11
 
15
12
  return unless resource
@@ -33,9 +30,10 @@ module DeviseOtt
33
30
  # Check if this is strategy is valid for ott authentication by:
34
31
  #
35
32
  # * If the ott token exists;
33
+ # * If ott module is included
36
34
  #
37
35
  def valid_for_ott_auth?
38
- params[:ott_token].present?
36
+ params[:ott_token].present? && mapping.to.respond_to?(:find_for_ott_authentication)
39
37
  end
40
38
  end
41
39
  end
@@ -1,3 +1,4 @@
1
+ require 'redis'
1
2
  require 'singleton'
2
3
 
3
4
  module DeviseOtt
@@ -1,3 +1,3 @@
1
1
  module DeviseOtt
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -0,0 +1,62 @@
1
+ require 'test_helper'
2
+
3
+ class DeviseOttTest < ActiveSupport::TestCase
4
+ test 'redis is present' do
5
+ class DeviseOtt::Tokens;attr_reader :redis;end
6
+
7
+ assert_equal('PONG', DeviseOtt::Tokens.instance.redis.ping)
8
+ end
9
+
10
+ test 'redis shuts down after finalize' do
11
+ class DeviseOtt::Tokens;class << self;attr_accessor :redis;end;end
12
+ DeviseOtt::Tokens.redis = DeviseOtt::Tokens.instance.redis
13
+
14
+ assert_nothing_raised { DeviseOtt::Tokens.finalize }
15
+ assert_equal('OK', DeviseOtt::Tokens.finalize)
16
+ end
17
+
18
+ test 'redis revokes' do
19
+ assert_equal(1, DeviseOtt::Tokens.instance.revoke('random_token'))
20
+ DeviseOtt::Tokens.instance.register('random_token', 'test1@example.com', 1040, 100100)
21
+ end
22
+
23
+ test 'accesses token for a given email if allowed' do
24
+ assert_equal(true, DeviseOtt::Tokens.instance.access('random_token', 'test1@example.com'))
25
+ end
26
+
27
+ test 'deny token access if not allowed' do
28
+ assert_equal(false, DeviseOtt::Tokens.instance.access('random_token', 'test2@example.com'))
29
+ end
30
+
31
+ test 'returns correct email if allowed' do
32
+ DeviseOtt::Tokens.instance.access('random_token', 'test1@example.com')
33
+ assert_equal('test1@example.com', DeviseOtt::Tokens.instance.email('random_token'))
34
+ end
35
+
36
+ test 'denies email access unless allowed' do
37
+ DeviseOtt::Tokens.instance.access('random_token', 'test1@example.com')
38
+ assert_equal(nil, DeviseOtt::Tokens.instance.email('random_token_'))
39
+ end
40
+
41
+ test 'loads config if allowed' do
42
+ class DeviseOtt::Tokens;public :load_config;end
43
+ assert_not_nil(DeviseOtt::Tokens.instance.load_config('random_token'))
44
+ end
45
+
46
+ test 'does not load config if disallowed' do
47
+ class DeviseOtt::Tokens;public :load_config;end
48
+ assert_equal(nil, DeviseOtt::Tokens.instance.load_config('random_token_'))
49
+ end
50
+
51
+ test 'returns ttl if allowed' do
52
+ class DeviseOtt::Tokens;public :ttl;end
53
+ ttl = DeviseOtt::Tokens.instance.ttl('random_token')
54
+ assert_send([ttl, :is_a?, Numeric])
55
+ assert_operator(ttl, :>, 0)
56
+ end
57
+
58
+ test 'does not return ttl unless allowed' do
59
+ class DeviseOtt::Tokens;public :ttl;end
60
+ refute_operator(DeviseOtt::Tokens.instance.ttl('random_token_'), :>, 0)
61
+ end
62
+ end
@@ -7,6 +7,11 @@ RailsApp::Application.configure do
7
7
  # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
+ # Rails 5 deprecation warning
11
+ Rails.application.configure do
12
+ config.active_support.test_order = :sorted
13
+ end
14
+
10
15
  # Show full error reports and disable caching
11
16
  config.consider_all_requests_local = true
12
17
  config.action_controller.perform_caching = false
@@ -0,0 +1,4 @@
1
+ User.create(email:'test1@example.com')
2
+ User.create(email:'test2@example.com')
3
+
4
+ DeviseOtt::Tokens.instance.register('random_token', 'test1@example.com', 1040, 100100)
data/test/test_helper.rb CHANGED
@@ -13,4 +13,4 @@ Coveralls.wear!
13
13
  require 'devise_ott'
14
14
  require 'rails_app/config/environment'
15
15
 
16
- Dir[File.join(TEST_ROOT, 'support/*.rb')].each{ |f| require f }
16
+ %w(schema models seed).each{ |f| require File.join(TEST_ROOT, "support/#{f}.rb") }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_ott
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iuri Gagnidze
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
11
+ date: 2015-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -138,6 +138,7 @@ files:
138
138
  - LICENSE.txt
139
139
  - README.rdoc
140
140
  - Rakefile
141
+ - certs/igagnidz.pem
141
142
  - devise_ott.gemspec
142
143
  - lib/devise_ott.rb
143
144
  - lib/devise_ott/models.rb
@@ -147,6 +148,7 @@ files:
147
148
  - lib/devise_ott/tokens.rb
148
149
  - lib/devise_ott/version.rb
149
150
  - test/devise_ott_test.rb
151
+ - test/devise_ott_tokens_test.rb
150
152
  - test/rails_app/app/controllers/application_controller.rb
151
153
  - test/rails_app/config/application.rb
152
154
  - test/rails_app/config/database.yml
@@ -157,6 +159,7 @@ files:
157
159
  - test/rails_app/config/routes.rb
158
160
  - test/support/models.rb
159
161
  - test/support/schema.rb
162
+ - test/support/seed.rb
160
163
  - test/test_helper.rb
161
164
  homepage: https://github.com/igagnidz/devise_ott
162
165
  licenses:
@@ -178,12 +181,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
181
  version: '0'
179
182
  requirements: []
180
183
  rubyforge_project:
181
- rubygems_version: 2.2.0.rc.1
184
+ rubygems_version: 2.4.5
182
185
  signing_key:
183
186
  specification_version: 4
184
187
  summary: Adds one time token authentication to devise
185
188
  test_files:
186
189
  - test/devise_ott_test.rb
190
+ - test/devise_ott_tokens_test.rb
187
191
  - test/rails_app/app/controllers/application_controller.rb
188
192
  - test/rails_app/config/application.rb
189
193
  - test/rails_app/config/database.yml
@@ -194,4 +198,5 @@ test_files:
194
198
  - test/rails_app/config/routes.rb
195
199
  - test/support/models.rb
196
200
  - test/support/schema.rb
201
+ - test/support/seed.rb
197
202
  - test/test_helper.rb