cookie_crypt 1.1.4 → 1.2.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 +4 -2
- data/app/controllers/devise/cookie_crypt_controller.rb +3 -2
- data/app/views/devise/cookie_crypt/_extra_fields.html.erb +1 -1
- data/app/views/devise/cookie_crypt/show.html.erb +7 -9
- data/app/views/devise/cookie_crypt/show.js.erb +6 -0
- data/lib/cookie_crypt/version.rb +1 -1
- data/lib/generators/active_record/cookie_crypt_generator.rb +1 -0
- data/lib/generators/cookie_crypt/cookie_crypt_generator.rb +48 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7577d9bb79387e429db3b9fc80d12fef8baf8c0
|
4
|
+
data.tar.gz: 55d8bc3a279e9ac333015defdbdf624511dd0f56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2fff4e687726ac1882bd082c042668c59c887696e01305d7d3c6b469328c0f7232f0a12c068ae32b566d4d60aa4cc44e72538044281a8958c1dc7b9a8267f2e
|
7
|
+
data.tar.gz: 62d200a43750fae54643231b38bbfbe745a3f6896ba125d789f1a6d83be5e7f3880e61a870fdaa1d833e1a516c2b4c8fb5f14e8ad54954f8851df0bb7183c6e0
|
data/README.md
CHANGED
@@ -29,7 +29,9 @@ In order to add encrypted cookie two factor authorization to a model, run the co
|
|
29
29
|
bundle exec rails g cookie_crypt MODEL
|
30
30
|
|
31
31
|
Where MODEL is your model name (e.g. User or Admin). This generator will add `:cookie_cryptable` to your model
|
32
|
-
and create a migration in `db/migrate/`, which will add the required columns to your table.
|
32
|
+
and create a migration in `db/migrate/`, which will add the required columns to your table. It will also generate
|
33
|
+
cookie crypt views in app/views/devise/cookie_crypt. You can delete these views if you'd rather just use the default
|
34
|
+
ones served from the gem.
|
33
35
|
|
34
36
|
### NOTE!
|
35
37
|
|
@@ -124,7 +126,7 @@ the question-auth.
|
|
124
126
|
* Default is 3
|
125
127
|
* The maximum number of tries a user has before they are locked out of cookie crypt and unable to fully login.
|
126
128
|
* cookie_deletion_time_frame
|
127
|
-
* Default is '30.days.
|
129
|
+
* Default is '30.days.from_now'
|
128
130
|
* Must be a string that evaluates to a date in the future.
|
129
131
|
|
130
132
|
### Rationalle
|
@@ -26,6 +26,7 @@ class Devise::CookieCryptController < DeviseController
|
|
26
26
|
else
|
27
27
|
flash[:notice] = "Signed In Successfully, now going through two factor authentication."
|
28
28
|
@user = resource
|
29
|
+
@request_path = request.fullpath.split('?').first
|
29
30
|
render template: "devise/cookie_crypt/show"
|
30
31
|
end
|
31
32
|
end
|
@@ -55,10 +56,10 @@ class Devise::CookieCryptController < DeviseController
|
|
55
56
|
resource.save
|
56
57
|
|
57
58
|
authentication_success
|
58
|
-
else
|
59
|
+
else #normal login attempts
|
59
60
|
|
60
61
|
if matching_answers?(h)
|
61
|
-
generate_cookie
|
62
|
+
generate_cookie unless params[:do_not_save_cookie]
|
62
63
|
update_resource_cycle(h)
|
63
64
|
log_agent_to_resource
|
64
65
|
authentication_success
|
@@ -9,6 +9,6 @@
|
|
9
9
|
<%=text_field_tag "security_answer_#{session[:cookie_crypt_questions_count]}", nil, size: 50, name: "security[security_answer_#{session[:cookie_crypt_questions_count]}]" %>
|
10
10
|
<br></br>
|
11
11
|
|
12
|
-
<%= link_to "Remove this question / answer pair?", "#{
|
12
|
+
<%= link_to "Remove this question / answer pair?", "#{@request_path}?remove=#{session[:cookie_crypt_questions_count]}", remote: true %>
|
13
13
|
<br></br>
|
14
14
|
</div>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
|
24
24
|
<% if @user.class.enable_custom_question_counts %>
|
25
25
|
<div id="cookie_crypt_additions_binder"></div>
|
26
|
-
<%= link_to "Add more security questions and answers?",
|
26
|
+
<%= link_to "Add more security questions and answers?", @request_path, remote: true %>
|
27
27
|
<br></br>
|
28
28
|
<% end %>
|
29
29
|
|
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
<% if @user.class.enable_custom_question_counts %>
|
62
62
|
<div id="cookie_crypt_additions_binder"></div>
|
63
|
-
<%= link_to "Add more security questions and answers?",
|
63
|
+
<%= link_to "Add more security questions and answers?", @request_path, remote: true %>
|
64
64
|
<br></br>
|
65
65
|
<% end %>
|
66
66
|
|
@@ -68,17 +68,15 @@
|
|
68
68
|
<br></br>
|
69
69
|
<% else %>
|
70
70
|
|
71
|
-
<%
|
72
|
-
|
73
|
-
<% @questions.each do |q| %>
|
71
|
+
<% #Begin 1.2 changes %>
|
74
72
|
|
75
|
-
|
73
|
+
<div id="cookie_crypt_login_binder">
|
76
74
|
|
77
|
-
<%=
|
75
|
+
<%= render partial: 'private_login_questions' %>
|
78
76
|
|
79
|
-
|
77
|
+
</div>
|
80
78
|
|
81
|
-
<%
|
79
|
+
<% #End 1.2 Changes %>
|
82
80
|
|
83
81
|
<% end %>
|
84
82
|
|
@@ -1,5 +1,11 @@
|
|
1
1
|
<% if params[:remove] %>
|
2
2
|
$('#security_binder_<%= params[:remove] %>').remove();
|
3
|
+
<% elsif params[:bind_public_form] %>
|
4
|
+
$('#cookie_crypt_login_binder').empty();
|
5
|
+
$('#cookie_crypt_login_binder').append('<%= escape_javascript(render partial: "public_login_questions")%>');
|
6
|
+
<% elsif params[:bind_private_form] %>
|
7
|
+
$('#cookie_crypt_login_binder').empty();
|
8
|
+
$('#cookie_crypt_login_binder').append('<%= escape_javascript(render partial: "private_login_questions")%>');
|
3
9
|
<% else %>
|
4
10
|
<% session[:cookie_crypt_questions_count] ||= @user.class.cookie_crypt_minimum_questions %>
|
5
11
|
<% session[:cookie_crypt_questions_count] += 1 %>
|
data/lib/cookie_crypt/version.rb
CHANGED
@@ -17,6 +17,7 @@ module ActiveRecord
|
|
17
17
|
|
18
18
|
def copy_cookie_crypt_migration_1_0
|
19
19
|
if ActiveRecord::Base.class_eval("#{table_name.camelize.singularize}.inspect['security_question_one: string'].blank?") &&
|
20
|
+
ActiveRecord::Base.class_eval("#{table_name.camelize.singularize}.inspect['security_hash: text'].blank?") &&
|
20
21
|
!@ignore_other_migrations
|
21
22
|
|
22
23
|
migration_template "migration.rb", "db/migrate/cookie_crypt_add_to_#{table_name}"
|
@@ -6,7 +6,8 @@ module CookieCryptable
|
|
6
6
|
|
7
7
|
#BEGIN 1.0 generator
|
8
8
|
def inject_1_0_cookie_crypt_content
|
9
|
-
if ActiveRecord::Base.class_eval("#{table_name.camelize.singularize}.inspect['security_question_one: string'].blank?")
|
9
|
+
if ActiveRecord::Base.class_eval("#{table_name.camelize.singularize}.inspect['security_question_one: string'].blank?") &&
|
10
|
+
ActiveRecord::Base.class_eval("#{table_name.camelize.singularize}.inspect['security_hash: text'].blank?")
|
10
11
|
puts "Beginning 1.0 content injection..."
|
11
12
|
paths = [File.join("app", "models", "#{file_path}.rb"),File.join("config", "initializers", "devise.rb")]
|
12
13
|
inject_into_file(paths[0], "cookie_cryptable, :", :after => "devise :") if File.exists?(paths[0])
|
@@ -20,13 +21,15 @@ module CookieCryptable
|
|
20
21
|
|
21
22
|
source_root File.expand_path('../../../../app/views/devise/cookie_crypt', __FILE__)
|
22
23
|
|
23
|
-
def
|
24
|
+
def generate_1_0_view_files
|
24
25
|
Dir.mkdir("app/views/devise") unless Dir.exists?("app/views/devise")
|
25
26
|
unless Dir.exists?("app/views/devise/cookie_crypt")
|
26
27
|
puts "Beginning 1.0 views creation..."
|
27
28
|
Dir.mkdir("app/views/devise/cookie_crypt")
|
28
29
|
copy_file "max_login_attempts_reached.html.erb", "app/views/devise/cookie_crypt/max_login_attempts_reached.html.erb"
|
29
30
|
copy_file "show.html.erb", "app/views/devise/cookie_crypt/show.html.erb"
|
31
|
+
|
32
|
+
$load_all_views = true
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
@@ -55,11 +58,13 @@ module CookieCryptable
|
|
55
58
|
|
56
59
|
source_root File.expand_path('../../../../app/views/devise/cookie_crypt', __FILE__)
|
57
60
|
|
58
|
-
def
|
61
|
+
def generate_1_1_view_files
|
59
62
|
unless File.exist?("app/views/devise/cookie_crypt/show.js.erb")
|
60
63
|
puts "Beginning 1.1 views creation..."
|
61
64
|
copy_file "show.js.erb", "app/views/devise/cookie_crypt/show.js.erb"
|
62
65
|
copy_file "_extra_fields.html.erb", "app/views/devise/cookie_crypt/_extra_fields.html.erb"
|
66
|
+
copy_file "_private_login_questions.html.erb", "app/views/devise/cookie_crypt/_private_login_questions.html.erb"
|
67
|
+
copy_file "_public_login_questions.html.erb", "app/views/devise/cookie_crypt/_public_login_questions.html.erb"
|
63
68
|
File.delete("app/views/devise/cookie_crypt/show.html.erb")
|
64
69
|
copy_file "show.html.erb", "app/views/devise/cookie_crypt/show.html.erb"
|
65
70
|
end
|
@@ -90,6 +95,46 @@ module CookieCryptable
|
|
90
95
|
end
|
91
96
|
end
|
92
97
|
|
98
|
+
def generate_1_2_view_files
|
99
|
+
$load_all_views ||= false
|
100
|
+
unless File.exist?("app/views/devise/cookie_crypt/_private_login_questions.html.erb")
|
101
|
+
unless $load_all_views
|
102
|
+
copy_new_files = false
|
103
|
+
puts "Enter O || o || overwrite to overwrite the view files in app/views/devise/cookie_crypt\n"
|
104
|
+
puts "Enter CO || co || copyover to write new files to app/views/devise/cookie_crypt (you will need to update show.js.erb and show.html.haml yourself)\n"
|
105
|
+
puts "Enter N || n || no to not generate anything\n"
|
106
|
+
puts "Input:"
|
107
|
+
input = STDIN.gets.chomp
|
108
|
+
end
|
109
|
+
|
110
|
+
if (input =~ /O|o|overwrite/) == 0
|
111
|
+
puts "Beginning 1.2 views creation..."
|
112
|
+
File.delete("app/views/devise/cookie_crypt/show.js.erb")
|
113
|
+
copy_file "show.js.erb", "app/views/devise/cookie_crypt/show.js.erb"
|
114
|
+
File.delete("app/views/devise/cookie_crypt/show.html.erb")
|
115
|
+
copy_file "show.html.erb", "app/views/devise/cookie_crypt/show.html.erb"
|
116
|
+
File.delete("app/views/devise/cookie_crypt/_extra_fields.html.erb")
|
117
|
+
copy_new_files = true
|
118
|
+
elsif (input =~ /CO|co|copyover/) == 0
|
119
|
+
puts "Beginning 1.2 views creation...(please update the view files yourself)"
|
120
|
+
copy_file "show.js.erb", "app/views/devise/cookie_crypt/(copy_into_your)show.js.erb"
|
121
|
+
copy_file "show.html.erb", "app/views/devise/cookie_crypt/(copy_into_your)show.html.erb"
|
122
|
+
copy_file "_extra_fields.html.erb", "app/views/devise/cookie_crypt/(copy_into_your)_extra_fields.html.erb"
|
123
|
+
copy_new_files = true
|
124
|
+
elsif $load_all_views
|
125
|
+
puts "Beginning 1.2 views creation..."
|
126
|
+
copy_new_files = true
|
127
|
+
else
|
128
|
+
puts "Not updating view files.\nIf you dont want to deal with the cookie_crypt views, you can delete app/views/devise/cookie_crypt and the gem will serve the data."
|
129
|
+
end
|
130
|
+
|
131
|
+
if copy_new_files
|
132
|
+
copy_file "_private_login_questions.html.erb", "app/views/devise/cookie_crypt/_private_login_questions.html.erb"
|
133
|
+
copy_file "_public_login_questions.html.erb", "app/views/devise/cookie_crypt/_public_login_questions.html.erb"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
93
138
|
hook_for :orm
|
94
139
|
end
|
95
140
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookie_crypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitrii Golub
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project: cookie_crypt
|
141
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.1.11
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Encrypted cookie two factor authentication plugin for devise
|