two_factor_authentication 1.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86b64f6f26de2115a9fb9c35afd02072d4d668ab
4
- data.tar.gz: b6448de97e61ce3d00910f3a6b5b165ad683e642
3
+ metadata.gz: 8037c367e1a0f7f7d253be0457b2046488b628fa
4
+ data.tar.gz: 024269293da1e0a407ac4e3537dc4e8749ca95a5
5
5
  SHA512:
6
- metadata.gz: 17445687f19fe7f427b15c788423e1d7e26b90298e9e1c174a56168f3a7e6bb16172e4edb2fa6b3b7d27f17d54bc46119267524ce0fb6cf4a5946d0e8639eda9
7
- data.tar.gz: 3538d6195e8529e753eaaf5bf85a85f9c65eac7af9cf51c227fea2bfe2b42a01eb91be4909196bfe749a8e78e23c8e87ba12791255327e592ae54fd415a94ce7
6
+ metadata.gz: 0c5a7deda98812e0a46ced0f99f2c0af64d4cd57531aad76660fecc7a1b351ba776263b24066a3d1f8caa93279f97fba1d415bcf41caf13bb1bc627a3a0c49ba
7
+ data.tar.gz: 2c80f6553ff57dbc3257f20c345cdf2217eefcf7d543f7547c0c31f8e57dbfc94ccf27759acbf81ba3937b05a808a8cc42acbb3ce7ee1ee7cb4869379f02bbaf
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ language: ruby
3
3
  env:
4
4
  - "RAILS_VERSION=3.2.0"
5
5
  - "RAILS_VERSION=4.0.0"
6
+ - "RAILS_VERSION=4.1.1"
6
7
  - "RAILS_VERSION=master"
7
8
 
8
9
  rvm:
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Two factor authentication for Devise
2
2
 
3
3
  [![Build Status](https://travis-ci.org/Houdini/two_factor_authentication.svg?branch=master)](https://travis-ci.org/Houdini/two_factor_authentication)
4
+ [![Code Climate](https://codeclimate.com/github/Houdini/two_factor_authentication.png)](https://codeclimate.com/github/Houdini/two_factor_authentication)
4
5
 
5
6
  ## Features
6
7
 
@@ -9,7 +9,7 @@ class Devise::TwoFactorAuthenticationController < DeviseController
9
9
  render :show and return if params[:code].nil?
10
10
 
11
11
  if resource.authenticate_otp(params[:code])
12
- warden.session(resource_name)[:need_two_factor_authentication] = false
12
+ warden.session(resource_name)['need_two_factor_authentication'] = false
13
13
  sign_in resource_name, resource, :bypass => true
14
14
  set_flash_message :notice, :success
15
15
  redirect_to stored_location_for(resource_name) || :root
@@ -12,7 +12,7 @@ module TwoFactorAuthentication
12
12
  def handle_two_factor_authentication
13
13
  unless devise_controller?
14
14
  Devise.mappings.keys.flatten.any? do |scope|
15
- if signed_in?(scope) and warden.session(scope)[:need_two_factor_authentication]
15
+ if signed_in?(scope) and warden.session(scope)['need_two_factor_authentication']
16
16
  handle_failed_second_factor(scope)
17
17
  end
18
18
  end
@@ -42,7 +42,7 @@ module Devise
42
42
  module Controllers
43
43
  module Helpers
44
44
  def is_fully_authenticated?
45
- !session["warden.user.user.session"].try(:[], :need_two_factor_authentication)
45
+ !session["warden.user.user.session"].try(:[], 'need_two_factor_authentication')
46
46
  end
47
47
  end
48
48
  end
@@ -1,6 +1,6 @@
1
1
  Warden::Manager.after_authentication do |user, auth, options|
2
2
  if user.respond_to?(:need_two_factor_authentication?)
3
- if auth.session(options[:scope])[:need_two_factor_authentication] = user.need_two_factor_authentication?(auth.request)
3
+ if auth.session(options[:scope])['need_two_factor_authentication'] = user.need_two_factor_authentication?(auth.request)
4
4
  user.send_two_factor_authentication_code
5
5
  end
6
6
  end
@@ -32,7 +32,7 @@ module Devise
32
32
  end
33
33
 
34
34
  def otp_code(time = Time.now)
35
- ROTP::TOTP.new(self.otp_column).at(time)
35
+ ROTP::TOTP.new(self.otp_column).at(time, true)
36
36
  end
37
37
 
38
38
  def provisioning_uri(account = nil, options = {})
@@ -1,3 +1,3 @@
1
1
  module TwoFactorAuthentication
2
- VERSION = "1.1".freeze
2
+ VERSION = "1.1.1".freeze
3
3
  end
@@ -25,7 +25,15 @@ describe Devise::Models::TwoFactorAuthenticatable, '#otp_code' do
25
25
  let(:time) { 1392852756 }
26
26
 
27
27
  it "should return a known result" do
28
- expect(subject).to eq(562202)
28
+ expect(subject).to eq('562202')
29
+ end
30
+ end
31
+
32
+ context "with a known time yielding a result with less than 6 digits" do
33
+ let(:time) { 1393065856 }
34
+
35
+ it "should return a known result padded with zeroes" do
36
+ expect(subject).to eq('007672')
29
37
  end
30
38
  end
31
39
  end
@@ -0,0 +1,3 @@
1
+ if Rails.version > '4.1.0'
2
+ Rails.application.config.action_dispatch.cookies_serializer = :json
3
+ end
@@ -33,4 +33,5 @@ Gem::Specification.new do |s|
33
33
  s.add_development_dependency 'rake'
34
34
  s.add_development_dependency 'rspec-rails'
35
35
  s.add_development_dependency 'capybara'
36
+ s.add_development_dependency 'pry'
36
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: two_factor_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitrii Golub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-16 00:00:00.000000000 Z
11
+ date: 2014-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: |2
126
140
  ### Features ###
127
141
  * control sms code pattern
@@ -184,6 +198,7 @@ files:
184
198
  - spec/rails_app/config/environments/production.rb
185
199
  - spec/rails_app/config/environments/test.rb
186
200
  - spec/rails_app/config/initializers/backtrace_silencers.rb
201
+ - spec/rails_app/config/initializers/cookies_serializer.rb
187
202
  - spec/rails_app/config/initializers/devise.rb
188
203
  - spec/rails_app/config/initializers/inflections.rb
189
204
  - spec/rails_app/config/initializers/mime_types.rb
@@ -229,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
244
  version: '0'
230
245
  requirements: []
231
246
  rubyforge_project: two_factor_authentication
232
- rubygems_version: 2.1.11
247
+ rubygems_version: 2.2.2
233
248
  signing_key:
234
249
  specification_version: 4
235
250
  summary: Two factor authentication plugin for devise
@@ -261,6 +276,7 @@ test_files:
261
276
  - spec/rails_app/config/environments/production.rb
262
277
  - spec/rails_app/config/environments/test.rb
263
278
  - spec/rails_app/config/initializers/backtrace_silencers.rb
279
+ - spec/rails_app/config/initializers/cookies_serializer.rb
264
280
  - spec/rails_app/config/initializers/devise.rb
265
281
  - spec/rails_app/config/initializers/inflections.rb
266
282
  - spec/rails_app/config/initializers/mime_types.rb