devise_google_authenticator 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjMxZmMyYjM2ZWFkNzg3MGUzODE4ZGY0ODc2M2FjODBkN2M2NWJkMQ==
5
+ data.tar.gz: !binary |-
6
+ ZWVmODk0ZThjZDk4ZTA3YjFhNmNjOWJiMDZlYTZiNGIzYTY2YWYwYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YTk2YzQ0OGVkYzZhOTI1NTY3NjFiYmM3ZTRiMWZiOTU4YzNlZTcxYTQzNDBl
10
+ Y2NjMDgyYWVlYzA0ZDNlZjFkMmNmNzA3YjA2YzZiMTViMWQzMzA0MmFmNTQ5
11
+ YmUzOGMxYzYzNjg1NTY4NWFiMjIzZGNhNmZjM2IxMjA5ZWEwMGU=
12
+ data.tar.gz: !binary |-
13
+ YWZhM2YwNmM2MGJmYTAwZWYyZDM5Y2YxYTZlZGE3NjI2M2NiM2ZkMWM5MDg3
14
+ OTk4NjE2MjJhNjhhZDVjNzhjNGJhODk4MTVkZjA0MzAwNDBlODJlZGNjZjli
15
+ ZTY1NDA5ZGYyZGY4MDhjMmRjNjg4OWJkMWZiY2NkMGE3ODYwNzM=
data/README.rdoc CHANGED
@@ -12,13 +12,14 @@ This is a devise[https://github.com/plataformatec/devise] extension to allow you
12
12
  * Version 0.3.4 - Updated test cases to function properly, and tested working with Devise 2.2 (up to at least Devise 2.2.4)
13
13
  * Version 0.3.5 - Updated README for Rails apps with existing users. (Thanks Jon Collier)
14
14
  * Version 0.3.6 - Slight updates - increased key size, more open gemspec, updated en.yml. (Thanks Michael Guymon)
15
+ * Version 0.3.7 - Support for current Devise (3.2.0) and Rails4 (Thanks https://github.com/ronald05arias) - integration test still broke - need to address this
15
16
 
16
17
  == Installation
17
18
 
18
19
  Add the gem to your Gemfile (don't forget devise too):
19
20
 
20
21
  * gem 'devise'
21
- * gem 'devise_google_authenticator', '0.3.6'
22
+ * gem 'devise_google_authenticator', '0.3.7'
22
23
 
23
24
  Don't forget to "bundle install"
24
25
 
@@ -1,7 +1,9 @@
1
1
  class Devise::CheckgaController < Devise::SessionsController
2
+ prepend_before_filter :devise_resource, :only => [:show]
2
3
  prepend_before_filter :require_no_authentication, :only => [ :show, :update ]
4
+
3
5
  include Devise::Controllers::Helpers
4
-
6
+
5
7
  def show
6
8
  @tmpid = params[:id]
7
9
  if @tmpid.nil?
@@ -10,13 +12,13 @@ class Devise::CheckgaController < Devise::SessionsController
10
12
  render :show
11
13
  end
12
14
  end
13
-
15
+
14
16
  def update
15
17
  resource = resource_class.find_by_gauth_tmp(params[resource_name]['tmpid'])
16
18
 
17
19
  if not resource.nil?
18
20
 
19
- if resource.validate_token(params[resource_name]['token'].to_i)
21
+ if resource.validate_token(params[resource_name]['gauth_token'].to_i)
20
22
  set_flash_message(:notice, :signed_in) if is_navigational_format?
21
23
  sign_in(resource_name,resource)
22
24
  respond_with resource, :location => after_sign_in_path_for(resource)
@@ -28,4 +30,10 @@ class Devise::CheckgaController < Devise::SessionsController
28
30
  redirect_to :root
29
31
  end
30
32
  end
33
+
34
+ private
35
+
36
+ def devise_resource
37
+ self.resource = resource_class.new
38
+ end
31
39
  end
@@ -1,20 +1,19 @@
1
1
  class Devise::DisplayqrController < DeviseController
2
2
  prepend_before_filter :authenticate_scope!, :only => [:show,:update]
3
-
3
+
4
4
  include Devise::Controllers::Helpers
5
-
5
+
6
6
  def show
7
- if not resource.nil? and not resource.gauth_secret.nil?
8
- render :show
9
- else
7
+ if resource.nil? || resource.gauth_secret.nil?
10
8
  sign_in scope, resource, :bypass => true
11
9
  redirect_to stored_location_for(scope) || :root
10
+ else
11
+ render :show
12
12
  end
13
13
  end
14
-
14
+
15
15
  def update
16
- tmp = params[resource_name]
17
- if resource.set_gauth_enabled(params[resource_name])
16
+ if resource.set_gauth_enabled(resource_params)
18
17
  set_flash_message :notice, "Status Updated!"
19
18
  sign_in scope, resource, :bypass => true
20
19
  redirect_to stored_location_for(scope) || :root
@@ -22,14 +21,23 @@ class Devise::DisplayqrController < DeviseController
22
21
  render :show
23
22
  end
24
23
  end
25
-
24
+
26
25
  private
27
26
  def scope
28
27
  resource_name.to_sym
29
28
  end
30
-
29
+
31
30
  def authenticate_scope!
32
31
  send(:"authenticate_#{resource_name}!")
33
32
  self.resource = send("current_#{resource_name}")
34
33
  end
34
+
35
+ def resource_params
36
+ return params.require(resource_name.to_sym).permit(:gauth_enabled) if strong_parameters_enabled?
37
+ params
38
+ end
39
+
40
+ def strong_parameters_enabled?
41
+ defined?(ActionController::StrongParameters)
42
+ end
35
43
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  <%= form_for(resource, :as => resource_name, :url => [resource_name, :checkga], :html => { :method => :put }) do |f| %>
4
4
  <%= f.hidden_field :tmpid, {:value => @tmpid} %>
5
- <%= f.text_field :token, :autocomplete => :off%>
5
+ <%= f.text_field :gauth_token, :autocomplete => :off%>
6
6
  <p><%= f.submit I18n.t('submit_token', {:scope => 'devise'}) %></p>
7
7
  <% end %>
@@ -18,9 +18,9 @@ module Devise # :nodoc:
18
18
  def get_qr
19
19
  self.gauth_secret
20
20
  end
21
-
22
- def set_gauth_enabled(param)
23
- self.update_without_password(param)
21
+
22
+ def set_gauth_enabled(params)
23
+ self.update_without_password(params)
24
24
  end
25
25
 
26
26
  def assign_tmp
@@ -40,7 +40,7 @@ module Devise # :nodoc:
40
40
  valid_vals << ROTP::TOTP.new(self.get_qr).at(Time.now.ago(30*cc))
41
41
  valid_vals << ROTP::TOTP.new(self.get_qr).at(Time.now.in(30*cc))
42
42
  end
43
-
43
+
44
44
  if valid_vals.include?(token.to_i)
45
45
  return true
46
46
  else
@@ -19,7 +19,7 @@ module DeviseGoogleAuthenticator::Patches
19
19
  respond_with resource, :location => { :controller => 'checkga', :action => 'show', :id => tmpid}
20
20
 
21
21
  else #It's not using, or not enabled for Google 2FA - carry on, nothing to see here.
22
- set_flash_message(:notice, :signed_in) if is_navigational_format?
22
+ set_flash_message(:notice, :signed_in) if is_flashing_format?
23
23
  sign_in(resource_name, resource)
24
24
  respond_with resource, :location => after_sign_in_path_for(resource)
25
25
  end
@@ -8,17 +8,18 @@ module DeviseGoogleAuthenticator::Patches
8
8
  alias_method :create_original, :create
9
9
 
10
10
  define_method :create do
11
- build_resource
11
+ build_resource(sign_up_params)
12
12
 
13
13
  if resource.save
14
+ yield resource if block_given?
14
15
  if resource.active_for_authentication?
15
- set_flash_message :notice, :signed_up if is_navigational_format?
16
+ set_flash_message :notice, :signed_up if is_flashing_format?
16
17
  sign_in(resource_name, resource)
17
18
 
18
19
  respond_with resource, :location => {:controller => 'displayqr', :action => 'show'}
19
20
  else
20
- set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_navigational_format?
21
- expire_session_data_after_sign_in!
21
+ set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
22
+ expire_data_after_sign_in!
22
23
  respond_with resource, :location => after_inactive_sign_up_path_for(resource)
23
24
  end
24
25
  else
@@ -8,12 +8,30 @@ module DeviseGoogleAuthenticator
8
8
 
9
9
  def inject_devise_google_authenticator_content
10
10
  path = File.join("app","models","#{file_path}.rb")
11
- inject_into_file(path, "google_authenticatable, :", :after => "devise :") if File.exists?(path)
12
- inject_into_file(path, "gauth_enabled, :gauth_tmp, :gauth_tmp_datetime, :", :after => "attr_accessible :") if File.exists?(path)
11
+
12
+ if File.exists?(path)
13
+ inject_into_file(path, "google_authenticatable, :", :after => "devise :")
14
+ inject_into_file(path, "gauth_enabled, :gauth_tmp, :gauth_tmp_datetime, :", :after => "attr_accessible :") if needs_attr_accessible?
15
+ inject_into_class(path, class_name, "\tattr_accessor :gauth_token\n")
16
+ end
13
17
  end
14
18
 
15
19
  hook_for :orm
16
20
 
21
+ private
22
+
23
+ def needs_attr_accessible?
24
+ rails_3? && !strong_parameters_enabled?
25
+ end
26
+
27
+ def rails_3?
28
+ Rails::VERSION::MAJOR == 3
29
+ end
30
+
31
+ def strong_parameters_enabled?
32
+ defined?(ActionController::StrongParameters)
33
+ end
34
+
17
35
  end
18
36
  end
19
37
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_google_authenticator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
5
- prerelease:
4
+ version: 0.3.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Christian Frichot
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-13 00:00:00.000000000 Z
11
+ date: 2013-12-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,55 +27,48 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: railties
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - ! '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '3.0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - ! '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '3.0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: actionmailer
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - ! '>='
52
46
  - !ruby/object:Gem::Version
53
- version: '3.0'
47
+ version: 3.2.12
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
- version: '3.0'
54
+ version: 3.2.12
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: devise
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
69
- version: 2.2.0
61
+ version: 3.2.0
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
77
- version: 2.2.0
68
+ version: 3.2.0
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rotp
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -125,26 +114,25 @@ files:
125
114
  homepage: http://github.com/AsteriskLabs/devise_google_authenticator
126
115
  licenses:
127
116
  - MIT
117
+ metadata: {}
128
118
  post_install_message:
129
119
  rdoc_options: []
130
120
  require_paths:
131
121
  - lib
132
122
  required_ruby_version: !ruby/object:Gem::Requirement
133
- none: false
134
123
  requirements:
135
124
  - - ! '>='
136
125
  - !ruby/object:Gem::Version
137
- version: 1.8.6
126
+ version: 1.9.2
138
127
  required_rubygems_version: !ruby/object:Gem::Requirement
139
- none: false
140
128
  requirements:
141
129
  - - ! '>='
142
130
  - !ruby/object:Gem::Version
143
- version: 1.3.6
131
+ version: 2.1.0
144
132
  requirements: []
145
133
  rubyforge_project:
146
- rubygems_version: 1.8.24
134
+ rubygems_version: 2.1.11
147
135
  signing_key:
148
- specification_version: 3
136
+ specification_version: 4
149
137
  summary: Devise Google Authenticator Extension
150
138
  test_files: []