safeguard-devise 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +15 -0
  2. data/.vagrant/machines/default/virtualbox/action_provision +1 -0
  3. data/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  4. data/.vagrant/machines/default/virtualbox/id +1 -0
  5. data/Gemfile +25 -0
  6. data/Gemfile.lock +186 -0
  7. data/Rakefile +51 -0
  8. data/VERSION +1 -0
  9. data/Vagrantfile +128 -0
  10. data/app/controllers/devise/devise_safeguard_controller.rb +56 -0
  11. data/app/views/devise/verify_safeguard.html.erb +9 -0
  12. data/app/views/devise/verify_safeguard.html.haml +7 -0
  13. data/config/locales/pt-BR.yml +5 -0
  14. data/lib/devise-safeguard/controllers/helpers.rb +54 -0
  15. data/lib/devise-safeguard/hooks/safeguard_authenticatable.rb +7 -0
  16. data/lib/devise-safeguard/models/safeguard_authenticatable.rb +18 -0
  17. data/lib/devise-safeguard/rails.rb +7 -0
  18. data/lib/devise-safeguard/routes.rb +17 -0
  19. data/lib/generators/active_record/devise_safeguard_generator.rb +13 -0
  20. data/lib/generators/active_record/templates/migration.rb +15 -0
  21. data/lib/generators/devise_safeguard/devise_safeguard_generator.rb +30 -0
  22. data/lib/generators/devise_safeguard/install_generator.rb +44 -0
  23. data/lib/safeguard-devise.rb +24 -0
  24. data/puppet/manifests/default.pp +66 -0
  25. data/puppet/modules/elasticsearch/CHANGELOG +62 -0
  26. data/puppet/modules/elasticsearch/CONTRIBUTORS +20 -0
  27. data/puppet/modules/elasticsearch/LICENSE +13 -0
  28. data/puppet/modules/elasticsearch/Modulefile +9 -0
  29. data/puppet/modules/elasticsearch/README.md +147 -0
  30. data/puppet/modules/elasticsearch/Rakefile +5 -0
  31. data/puppet/modules/elasticsearch/manifests/config.pp +64 -0
  32. data/puppet/modules/elasticsearch/manifests/init.pp +208 -0
  33. data/puppet/modules/elasticsearch/manifests/java.pp +50 -0
  34. data/puppet/modules/elasticsearch/manifests/package.pp +84 -0
  35. data/puppet/modules/elasticsearch/manifests/params.pp +103 -0
  36. data/puppet/modules/elasticsearch/manifests/plugin.pp +97 -0
  37. data/puppet/modules/elasticsearch/manifests/python.pp +34 -0
  38. data/puppet/modules/elasticsearch/manifests/service.pp +114 -0
  39. data/puppet/modules/elasticsearch/manifests/template.pp +118 -0
  40. data/puppet/modules/elasticsearch/metadata.json +41 -0
  41. data/puppet/modules/elasticsearch/spec/classes/elasticsearch_init_spec.rb +596 -0
  42. data/puppet/modules/elasticsearch/spec/defines/template_spec.rb +66 -0
  43. data/puppet/modules/elasticsearch/spec/spec_helper.rb +2 -0
  44. data/puppet/modules/elasticsearch/templates/etc/default/elasticsearch.erb +5 -0
  45. data/puppet/modules/elasticsearch/templates/etc/elasticsearch/elasticsearch.yml.erb +93 -0
  46. data/puppet/modules/memcached/.gitignore +2 -0
  47. data/puppet/modules/memcached/Modulefile +8 -0
  48. data/puppet/modules/memcached/README.md +29 -0
  49. data/puppet/modules/memcached/manifests/init.pp +33 -0
  50. data/puppet/modules/memcached/manifests/params.pp +21 -0
  51. data/puppet/modules/memcached/templates/memcached.conf.erb +46 -0
  52. data/puppet/modules/memcached/templates/memcached_sysconfig.erb +5 -0
  53. data/puppet/modules/mysql/.fixtures.yml +3 -0
  54. data/puppet/modules/mysql/.gemfile +5 -0
  55. data/puppet/modules/mysql/LICENSE +201 -0
  56. data/puppet/modules/mysql/Modulefile +8 -0
  57. data/puppet/modules/mysql/README.md +124 -0
  58. data/puppet/modules/mysql/files/mysqltuner.pl +966 -0
  59. data/puppet/modules/mysql/lib/puppet/parser/functions/mysql_password.rb +15 -0
  60. data/puppet/modules/mysql/lib/puppet/provider/database/mysql.rb +42 -0
  61. data/puppet/modules/mysql/lib/puppet/provider/database_grant/mysql.rb +177 -0
  62. data/puppet/modules/mysql/lib/puppet/provider/database_user/mysql.rb +42 -0
  63. data/puppet/modules/mysql/lib/puppet/type/database.rb +17 -0
  64. data/puppet/modules/mysql/lib/puppet/type/database_grant.rb +75 -0
  65. data/puppet/modules/mysql/lib/puppet/type/database_user.rb +25 -0
  66. data/puppet/modules/mysql/manifests/backup.pp +68 -0
  67. data/puppet/modules/mysql/manifests/config.pp +122 -0
  68. data/puppet/modules/mysql/manifests/db.pp +77 -0
  69. data/puppet/modules/mysql/manifests/init.pp +24 -0
  70. data/puppet/modules/mysql/manifests/java.pp +24 -0
  71. data/puppet/modules/mysql/manifests/params.pp +91 -0
  72. data/puppet/modules/mysql/manifests/python.pp +26 -0
  73. data/puppet/modules/mysql/manifests/ruby.pp +28 -0
  74. data/puppet/modules/mysql/manifests/server/account_security.pp +13 -0
  75. data/puppet/modules/mysql/manifests/server/monitor.pp +19 -0
  76. data/puppet/modules/mysql/manifests/server/mysqltuner.pp +22 -0
  77. data/puppet/modules/mysql/manifests/server.pp +52 -0
  78. data/puppet/modules/mysql/templates/my.cnf.erb +42 -0
  79. data/puppet/modules/mysql/templates/my.cnf.pass.erb +6 -0
  80. data/puppet/modules/mysql/templates/mysqlbackup.sh.erb +23 -0
  81. data/puppet/modules/postgresql/GPL-3 +674 -0
  82. data/puppet/modules/postgresql/Modulefile +13 -0
  83. data/puppet/modules/postgresql/README.md +156 -0
  84. data/puppet/modules/postgresql/lib/puppet/provider/pg_database/debian_postgresql.rb +30 -0
  85. data/puppet/modules/postgresql/lib/puppet/provider/pg_database/default.rb +17 -0
  86. data/puppet/modules/postgresql/lib/puppet/provider/pg_user/debian_postgresql.rb +63 -0
  87. data/puppet/modules/postgresql/lib/puppet/provider/pg_user/default.rb +17 -0
  88. data/puppet/modules/postgresql/lib/puppet/type/pg_database.rb +29 -0
  89. data/puppet/modules/postgresql/lib/puppet/type/pg_user.rb +45 -0
  90. data/puppet/modules/postgresql/manifests/db.pp +20 -0
  91. data/puppet/modules/postgresql/manifests/init.pp +12 -0
  92. data/puppet/modules/postgresql/manifests/params.pp +15 -0
  93. data/puppet/modules/postgresql/manifests/server.pp +47 -0
  94. data/puppet/modules/postgresql/templates/pg_hba.conf.erb +105 -0
  95. data/puppet/modules/postgresql/templates/postgresql.conf.erb +559 -0
  96. data/puppet/modules/redis/CHANGELOG +41 -0
  97. data/puppet/modules/redis/Gemfile +7 -0
  98. data/puppet/modules/redis/Gemfile.lock +18 -0
  99. data/puppet/modules/redis/Modulefile +10 -0
  100. data/puppet/modules/redis/README.md +34 -0
  101. data/puppet/modules/redis/Rakefile +6 -0
  102. data/puppet/modules/redis/manifests/init.pp +153 -0
  103. data/puppet/modules/redis/manifests/params.pp +39 -0
  104. data/puppet/modules/redis/metadata.json +31 -0
  105. data/puppet/modules/redis/spec/spec_helper.rb +17 -0
  106. data/puppet/modules/redis/templates/redis.debian.conf.erb +217 -0
  107. data/puppet/modules/redis/templates/redis.logrotate.erb +9 -0
  108. data/puppet/modules/redis/templates/redis.rhel.conf.erb +547 -0
  109. data/puppet/modules/redis/tests/init.pp +8 -0
  110. data/puppet/upgrade-puppet.sh +16 -0
  111. data/safeguard-devise.gemspec +249 -0
  112. data/spec/controllers/safeguard_devise_controller_spec.rb +67 -0
  113. data/spec/devise/safeguard_authenticatable_spec.rb +71 -0
  114. data/spec/orm/active_record.rb +4 -0
  115. data/spec/routing/routes_spec.rb +13 -0
  116. data/spec/safeguard-devise-test-app/.gitignore +16 -0
  117. data/spec/safeguard-devise-test-app/Gemfile +14 -0
  118. data/spec/safeguard-devise-test-app/Gemfile.lock +119 -0
  119. data/spec/safeguard-devise-test-app/README.rdoc +28 -0
  120. data/spec/safeguard-devise-test-app/Rakefile +6 -0
  121. data/spec/safeguard-devise-test-app/app/assets/images/.keep +0 -0
  122. data/spec/safeguard-devise-test-app/app/assets/javascripts/application.js +13 -0
  123. data/spec/safeguard-devise-test-app/app/assets/stylesheets/application.css +13 -0
  124. data/spec/safeguard-devise-test-app/app/controllers/application_controller.rb +5 -0
  125. data/spec/safeguard-devise-test-app/app/controllers/concerns/.keep +0 -0
  126. data/spec/safeguard-devise-test-app/app/controllers/home_controller.rb +6 -0
  127. data/spec/safeguard-devise-test-app/app/helpers/application_helper.rb +2 -0
  128. data/spec/safeguard-devise-test-app/app/mailers/.keep +0 -0
  129. data/spec/safeguard-devise-test-app/app/models/.keep +0 -0
  130. data/spec/safeguard-devise-test-app/app/models/concerns/.keep +0 -0
  131. data/spec/safeguard-devise-test-app/app/models/user.rb +6 -0
  132. data/spec/safeguard-devise-test-app/app/views/devise/devise_safeguard/verify_safeguard.html.erb +9 -0
  133. data/spec/safeguard-devise-test-app/app/views/devise/devise_safeguard/verify_safeguard.html.haml +6 -0
  134. data/spec/safeguard-devise-test-app/app/views/home/index.html.erb +1 -0
  135. data/spec/safeguard-devise-test-app/app/views/layouts/application.html.erb +14 -0
  136. data/spec/safeguard-devise-test-app/bin/bundle +3 -0
  137. data/spec/safeguard-devise-test-app/bin/rails +4 -0
  138. data/spec/safeguard-devise-test-app/bin/rake +4 -0
  139. data/spec/safeguard-devise-test-app/config/application.rb +31 -0
  140. data/spec/safeguard-devise-test-app/config/boot.rb +4 -0
  141. data/spec/safeguard-devise-test-app/config/database.yml +25 -0
  142. data/spec/safeguard-devise-test-app/config/environment.rb +5 -0
  143. data/spec/safeguard-devise-test-app/config/environments/development.rb +29 -0
  144. data/spec/safeguard-devise-test-app/config/environments/production.rb +80 -0
  145. data/spec/safeguard-devise-test-app/config/environments/test.rb +36 -0
  146. data/spec/safeguard-devise-test-app/config/initializers/backtrace_silencers.rb +7 -0
  147. data/spec/safeguard-devise-test-app/config/initializers/devise.rb +259 -0
  148. data/spec/safeguard-devise-test-app/config/initializers/filter_parameter_logging.rb +4 -0
  149. data/spec/safeguard-devise-test-app/config/initializers/inflections.rb +16 -0
  150. data/spec/safeguard-devise-test-app/config/initializers/mime_types.rb +5 -0
  151. data/spec/safeguard-devise-test-app/config/initializers/secret_token.rb +12 -0
  152. data/spec/safeguard-devise-test-app/config/initializers/session_store.rb +3 -0
  153. data/spec/safeguard-devise-test-app/config/initializers/wrap_parameters.rb +14 -0
  154. data/spec/safeguard-devise-test-app/config/locales/devise.en.yml +59 -0
  155. data/spec/safeguard-devise-test-app/config/locales/devise.safeguard.pt-BR.yml +5 -0
  156. data/spec/safeguard-devise-test-app/config/locales/en.yml +23 -0
  157. data/spec/safeguard-devise-test-app/config/routes.rb +59 -0
  158. data/spec/safeguard-devise-test-app/config.ru +4 -0
  159. data/spec/safeguard-devise-test-app/db/migrate/20140220191103_create_users.rb +9 -0
  160. data/spec/safeguard-devise-test-app/db/migrate/20140220191247_add_devise_to_users.rb +49 -0
  161. data/spec/safeguard-devise-test-app/db/migrate/20140220191522_devise_safeguard_add_to_users.rb +15 -0
  162. data/spec/safeguard-devise-test-app/db/schema.rb +37 -0
  163. data/spec/safeguard-devise-test-app/db/seeds.rb +7 -0
  164. data/spec/safeguard-devise-test-app/lib/assets/.keep +0 -0
  165. data/spec/safeguard-devise-test-app/lib/tasks/.keep +0 -0
  166. data/spec/safeguard-devise-test-app/log/.keep +0 -0
  167. data/spec/safeguard-devise-test-app/public/404.html +58 -0
  168. data/spec/safeguard-devise-test-app/public/422.html +58 -0
  169. data/spec/safeguard-devise-test-app/public/500.html +57 -0
  170. data/spec/safeguard-devise-test-app/public/favicon.ico +0 -0
  171. data/spec/safeguard-devise-test-app/public/robots.txt +5 -0
  172. data/spec/safeguard-devise-test-app/test/controllers/.keep +0 -0
  173. data/spec/safeguard-devise-test-app/test/fixtures/.keep +0 -0
  174. data/spec/safeguard-devise-test-app/test/fixtures/users.yml +9 -0
  175. data/spec/safeguard-devise-test-app/test/helpers/.keep +0 -0
  176. data/spec/safeguard-devise-test-app/test/integration/.keep +0 -0
  177. data/spec/safeguard-devise-test-app/test/mailers/.keep +0 -0
  178. data/spec/safeguard-devise-test-app/test/models/.keep +0 -0
  179. data/spec/safeguard-devise-test-app/test/models/user_test.rb +7 -0
  180. data/spec/safeguard-devise-test-app/test/test_helper.rb +15 -0
  181. data/spec/safeguard-devise-test-app/vendor/assets/javascripts/.keep +0 -0
  182. data/spec/safeguard-devise-test-app/vendor/assets/stylesheets/.keep +0 -0
  183. data/spec/spec_helper.rb +31 -0
  184. data/spec/tests_helper/helpers.rb +34 -0
  185. metadata +381 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDZkMTc5ZTViMmQ3Mzk3ODgzMjgyNWM1MTc3N2MwODFkYjk5YmZlZA==
5
+ data.tar.gz: !binary |-
6
+ MmZkZDliOWYzZGQ3N2Q2MzYxYTM5ZTFlMjc3NDRkZjI0MDc1YWIwYQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NGEzNTBkNGUxNTYyZjU5YmVmOTBlYWIyYTg4NjY3NmMyNDI2MDc5YTVhMWMw
10
+ MGVjN2VlNGY1OTllMWUwNmVmZDZkMTgxMDk3NDI2NDNjMWZlOTMwMzJhZTFj
11
+ N2M5OTk4MjQ3OWMxMGUzYWY4MmM2NjZjYTE2YTk3ZDMxZTQ4ODE=
12
+ data.tar.gz: !binary |-
13
+ MWNhZTk3MjFhN2JmYTliZTBiYjkwMDQ3Yjk4NjFiOTA5MTQxMjI2YzM3NGE2
14
+ NmU1NjY4NDBlYTYwMGM3ZDgxNTY4ZWZkZTIzN2ExYjcyOTVmYmVkYWFhYjAz
15
+ NTAwOGUwYzY5MmNiMTllYjBiY2ZmNmRkNTgzNjUwMjM4NGI5MmI=
@@ -0,0 +1 @@
1
+ 1392821468
@@ -0,0 +1 @@
1
+ 1392821436
@@ -0,0 +1 @@
1
+ 27ebf715-ba1c-4328-8272-055d4474ba94
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "devise"
4
+ gem 'safeguard-api'
5
+
6
+ group :development do
7
+ gem "rspec"
8
+ gem "yard"
9
+ gem "rdoc"
10
+ gem "bundler"
11
+ gem "jeweler"
12
+ gem "simplecov"
13
+ gem "sass-rails"
14
+ gem "jquery-rails"
15
+ gem "pry"
16
+ end
17
+
18
+ group :test do
19
+ gem "rails"
20
+ gem "sqlite3"
21
+ gem 'rspec-rails'
22
+ gem 'database_cleaner'
23
+ gem 'capybara'
24
+ end
25
+
data/Gemfile.lock ADDED
@@ -0,0 +1,186 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actionmailer (0.6.1)
5
+ actionpack (>= 0.9.5)
6
+ actionpack (4.0.3)
7
+ activesupport (= 4.0.3)
8
+ builder (~> 3.1.0)
9
+ erubis (~> 2.7.0)
10
+ rack (~> 1.5.2)
11
+ rack-test (~> 0.6.2)
12
+ activemodel (4.0.3)
13
+ activesupport (= 4.0.3)
14
+ builder (~> 3.1.0)
15
+ activerecord (4.0.3)
16
+ activemodel (= 4.0.3)
17
+ activerecord-deprecated_finders (~> 1.0.2)
18
+ activesupport (= 4.0.3)
19
+ arel (~> 4.0.0)
20
+ activerecord-deprecated_finders (1.0.3)
21
+ activesupport (4.0.3)
22
+ i18n (~> 0.6, >= 0.6.4)
23
+ minitest (~> 4.2)
24
+ multi_json (~> 1.3)
25
+ thread_safe (~> 0.1)
26
+ tzinfo (~> 0.3.37)
27
+ addressable (2.3.5)
28
+ arel (4.0.2)
29
+ atomic (1.1.14)
30
+ bcrypt-ruby (3.1.2)
31
+ builder (3.1.4)
32
+ capybara (2.2.1)
33
+ mime-types (>= 1.16)
34
+ nokogiri (>= 1.3.3)
35
+ rack (>= 1.0.0)
36
+ rack-test (>= 0.5.4)
37
+ xpath (~> 2.0)
38
+ coderay (1.1.0)
39
+ database_cleaner (1.2.0)
40
+ descendants_tracker (0.0.3)
41
+ devise (3.2.3)
42
+ bcrypt-ruby (~> 3.0)
43
+ orm_adapter (~> 0.1)
44
+ railties (>= 3.2.6, < 5)
45
+ thread_safe (~> 0.1)
46
+ warden (~> 1.2.3)
47
+ diff-lcs (1.2.5)
48
+ docile (1.1.3)
49
+ erubis (2.7.0)
50
+ faraday (0.9.0)
51
+ multipart-post (>= 1.2, < 3)
52
+ git (1.2.6)
53
+ github_api (0.11.2)
54
+ addressable (~> 2.3)
55
+ descendants_tracker (~> 0.0.1)
56
+ faraday (~> 0.8, < 0.10)
57
+ hashie (>= 1.2)
58
+ multi_json (>= 1.7.5, < 2.0)
59
+ nokogiri (~> 1.6.0)
60
+ oauth2
61
+ hashie (2.0.5)
62
+ highline (1.6.20)
63
+ hike (1.2.3)
64
+ httpclient (2.3.4.1)
65
+ i18n (0.6.9)
66
+ jeweler (2.0.1)
67
+ builder
68
+ bundler (>= 1.0)
69
+ git (>= 1.2.5)
70
+ github_api
71
+ highline (>= 1.6.15)
72
+ nokogiri (>= 1.5.10)
73
+ rake
74
+ rdoc
75
+ jquery-rails (3.1.0)
76
+ railties (>= 3.0, < 5.0)
77
+ thor (>= 0.14, < 2.0)
78
+ json (1.8.1)
79
+ jwt (0.1.11)
80
+ multi_json (>= 1.5)
81
+ method_source (0.8.2)
82
+ mime-types (2.1)
83
+ mini_portile (0.5.2)
84
+ minitest (4.7.5)
85
+ multi_json (1.8.4)
86
+ multi_xml (0.5.5)
87
+ multipart-post (2.0.0)
88
+ nokogiri (1.6.1)
89
+ mini_portile (~> 0.5.0)
90
+ oauth2 (0.9.3)
91
+ faraday (>= 0.8, < 0.10)
92
+ jwt (~> 0.1.8)
93
+ multi_json (~> 1.3)
94
+ multi_xml (~> 0.5)
95
+ rack (~> 1.2)
96
+ orm_adapter (0.5.0)
97
+ pry (0.9.12.6)
98
+ coderay (~> 1.0)
99
+ method_source (~> 0.8)
100
+ slop (~> 3.4)
101
+ rack (1.5.2)
102
+ rack-test (0.6.2)
103
+ rack (>= 1.0)
104
+ rails (0.9.5)
105
+ actionmailer (>= 0.6.1)
106
+ actionpack (>= 1.4.0)
107
+ activerecord (>= 1.6.0)
108
+ rake (>= 0.4.15)
109
+ railties (4.0.3)
110
+ actionpack (= 4.0.3)
111
+ activesupport (= 4.0.3)
112
+ rake (>= 0.8.7)
113
+ thor (>= 0.18.1, < 2.0)
114
+ rake (10.1.1)
115
+ rdoc (4.1.1)
116
+ json (~> 1.4)
117
+ rspec (2.14.1)
118
+ rspec-core (~> 2.14.0)
119
+ rspec-expectations (~> 2.14.0)
120
+ rspec-mocks (~> 2.14.0)
121
+ rspec-core (2.14.7)
122
+ rspec-expectations (2.14.5)
123
+ diff-lcs (>= 1.1.3, < 2.0)
124
+ rspec-mocks (2.14.5)
125
+ rspec-rails (2.14.1)
126
+ actionpack (>= 3.0)
127
+ activemodel (>= 3.0)
128
+ activesupport (>= 3.0)
129
+ railties (>= 3.0)
130
+ rspec-core (~> 2.14.0)
131
+ rspec-expectations (~> 2.14.0)
132
+ rspec-mocks (~> 2.14.0)
133
+ safeguard-api (0.2.0)
134
+ httpclient (>= 2.3.4)
135
+ sass (3.2.14)
136
+ sass-rails (4.0.1)
137
+ railties (>= 4.0.0, < 5.0)
138
+ sass (>= 3.1.10)
139
+ sprockets-rails (~> 2.0.0)
140
+ simplecov (0.8.2)
141
+ docile (~> 1.1.0)
142
+ multi_json
143
+ simplecov-html (~> 0.8.0)
144
+ simplecov-html (0.8.0)
145
+ slop (3.4.7)
146
+ sprockets (2.11.0)
147
+ hike (~> 1.2)
148
+ multi_json (~> 1.0)
149
+ rack (~> 1.0)
150
+ tilt (~> 1.1, != 1.3.0)
151
+ sprockets-rails (2.0.1)
152
+ actionpack (>= 3.0)
153
+ activesupport (>= 3.0)
154
+ sprockets (~> 2.8)
155
+ sqlite3 (1.3.8)
156
+ thor (0.18.1)
157
+ thread_safe (0.1.3)
158
+ atomic
159
+ tilt (1.4.1)
160
+ tzinfo (0.3.38)
161
+ warden (1.2.3)
162
+ rack (>= 1.0)
163
+ xpath (2.0.0)
164
+ nokogiri (~> 1.3)
165
+ yard (0.8.7.3)
166
+
167
+ PLATFORMS
168
+ ruby
169
+
170
+ DEPENDENCIES
171
+ bundler
172
+ capybara
173
+ database_cleaner
174
+ devise
175
+ jeweler
176
+ jquery-rails
177
+ pry
178
+ rails
179
+ rdoc
180
+ rspec
181
+ rspec-rails
182
+ safeguard-api
183
+ sass-rails
184
+ simplecov
185
+ sqlite3
186
+ yard
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "safeguard-devise"
18
+ gem.homepage = "http://github.com/diegonakamashi/safeguard-devise"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{TODO: one-line summary of your gem}
21
+ gem.description = %Q{TODO: longer description of your gem}
22
+ gem.email = "diegonakamashi@gmail.com"
23
+ gem.authors = ["diegonakamashi"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ desc "Code coverage detail"
36
+ task :simplecov do
37
+ ENV['COVERAGE'] = "true"
38
+ Rake::Task['test'].execute
39
+ end
40
+
41
+ task :default => :test
42
+
43
+ require 'rdoc/task'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "safeguard-devise #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
data/Vagrantfile ADDED
@@ -0,0 +1,128 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+
8
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
9
+ # All Vagrant configuration is done here. The most common configuration
10
+ # options are documented and commented below. For a complete reference,
11
+ # please see the online documentation at vagrantup.com.
12
+
13
+ # Every Vagrant virtual environment requires a box to build off of.
14
+ config.vm.box = "precise32"
15
+
16
+ # The url from where the 'config.vm.box' box will be fetched if it
17
+ # doesn't already exist on the user's system.
18
+ config.vm.box_url = "http://files.vagrantup.com/precise32.box"
19
+ config.vm.hostname = 'vizir-dev-box'
20
+
21
+ # Create a forwarded port mapping which allows access to a specific port
22
+ # within the machine from a port on the host machine. In the example below,
23
+ # accessing "localhost:8080" will access port 80 on the guest machine.
24
+ # config.vm.network :forwarded_port, guest: 80, host: 8080
25
+
26
+ # Create a private network, which allows host-only access to the machine
27
+ # using a specific IP.
28
+ config.vm.network :private_network, ip: "192.168.33.20"
29
+
30
+ config.vm.network :forwarded_port, guest: 3000, host: 3333
31
+ # Create a public network, which generally matched to bridged network.
32
+ # Bridged networks make the machine appear as another physical device on
33
+ # your network.
34
+ # config.vm.network :public_network
35
+
36
+ # If true, then any SSH connections made will enable agent forwarding.
37
+ # Default value: false
38
+ # config.ssh.forward_agent = true
39
+
40
+ # Share an additional folder to the guest VM. The first argument is
41
+ # the path on the host to the actual folder. The second argument is
42
+ # the path on the guest to mount the folder. And the optional third
43
+ # argument is a set of non-required options.
44
+ config.vm.synced_folder ".", "/vagrant"
45
+
46
+ # Provider-specific configuration so you can fine-tune various
47
+ # backing providers for Vagrant. These expose provider-specific options.
48
+ # Example for VirtualBox:
49
+ #
50
+ config.vm.provider :virtualbox do |vb|
51
+ # Don't boot with headless mode
52
+ # vb.gui = true
53
+
54
+ # Use VBoxManage to customize the VM. For example to change memory:
55
+ vb.customize ["modifyvm", :id, "--memory", "1024"]
56
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
57
+ end
58
+ #
59
+ # View the documentation for the provider you're using for more
60
+ # information on available options.
61
+
62
+ # Enable provisioning with Puppet stand alone. Puppet manifests
63
+ # are contained in a directory path relative to this Vagrantfile.
64
+ # You will need to create the manifests directory and a manifest in
65
+ # the file base.pp in the manifests_path directory.
66
+ #
67
+ # An example Puppet manifest to provision the message of the day:
68
+ #
69
+ # # group { "puppet":
70
+ # # ensure => "present",
71
+ # # }
72
+ # #
73
+ # # File { owner => 0, group => 0, mode => 0644 }
74
+ # #
75
+ # # file { '/etc/motd':
76
+ # # content => "Welcome to your Vagrant-built virtual machine!
77
+ # # Managed by Puppet.\n"
78
+ # # }
79
+ #
80
+ # config.vm.provision :puppet do |puppet|
81
+ # puppet.manifests_path = "manifests"
82
+ # puppet.manifest_file = "site.pp"
83
+ # end
84
+
85
+ # config.vm.provision :shell, :path => "puppet/upgrade-puppet.sh"
86
+ config.vm.provision :puppet do |puppet|
87
+ puppet.manifests_path = 'puppet/manifests'
88
+ puppet.module_path = 'puppet/modules'
89
+ end
90
+
91
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
92
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
93
+ # some recipes and/or roles.
94
+ #
95
+ # config.vm.provision :chef_solo do |chef|
96
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
97
+ # chef.roles_path = "../my-recipes/roles"
98
+ # chef.data_bags_path = "../my-recipes/data_bags"
99
+ # chef.add_recipe "mysql"
100
+ # chef.add_role "web"
101
+ #
102
+ # # You may also specify custom JSON attributes:
103
+ # chef.json = { :mysql_password => "foo" }
104
+ # end
105
+
106
+ # Enable provisioning with chef server, specifying the chef server URL,
107
+ # and the path to the validation key (relative to this Vagrantfile).
108
+ #
109
+ # The Opscode Platform uses HTTPS. Substitute your organization for
110
+ # ORGNAME in the URL and validation key.
111
+ #
112
+ # If you have your own Chef Server, use the appropriate URL, which may be
113
+ # HTTP instead of HTTPS depending on your configuration. Also change the
114
+ # validation key to validation.pem.
115
+ #
116
+ # config.vm.provision :chef_client do |chef|
117
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
118
+ # chef.validation_key_path = "ORGNAME-validator.pem"
119
+ # end
120
+ #
121
+ # If you're using the Opscode platform, your validator client is
122
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
123
+ #
124
+ # If you have your own Chef Server, the default validation client name is
125
+ # chef-validator, unless you changed the configuration.
126
+ #
127
+ # chef.validation_client_name = "ORGNAME-validator"
128
+ end
@@ -0,0 +1,56 @@
1
+ class Devise::DeviseSafeguardController < DeviseController
2
+ include Devise::Controllers::Helpers
3
+
4
+ before_filter :find_resource_and_require_password_checked
5
+
6
+ def GET_verify_safeguard
7
+ render 'verify_safeguard'
8
+ end
9
+
10
+ def POST_verify_safeguard
11
+ if token_ok?
12
+ @resource.update_attribute(:last_sign_in_with_safeguard, DateTime.now)
13
+
14
+ #remember_device if params[:remember_device].to_i == 1
15
+ if session.delete("#{resource_name}_remember_me") == true && @resource.respond_to?(:remember_me=)
16
+ @resource.remember_me = true
17
+ end
18
+ sign_in(resource_name, @resource)
19
+
20
+ set_flash_message(:notice, :signed_in) if is_navigational_format?
21
+ respond_with resource, :location => after_sign_in_path_for(@resource)
22
+ else
23
+ set_flash_message(:error, :invalid_token)
24
+ render :verify_safeguard
25
+ end
26
+ end
27
+
28
+ def token_ok?
29
+ resp = Safeguard::API.is_valid?({
30
+ :email => @resource.email,
31
+ :token => params[:safeguard_token]
32
+ })
33
+ resp
34
+ end
35
+
36
+
37
+ def find_resource
38
+ @resource = send("current_#{resource_name}")
39
+
40
+ if @resource.nil?
41
+ @resource = resource_class.find_by_id(session["#{resource_name}_id"])
42
+ end
43
+ end
44
+
45
+ def find_resource_and_require_password_checked
46
+ find_resource
47
+
48
+ if @resource.nil? || session[:"#{resource_name}_password_checked"].to_s != "true"
49
+ redirect_to invalid_resource_path
50
+ end
51
+ end
52
+
53
+ def invalid_resource_path
54
+ root_path
55
+ end
56
+ end
@@ -0,0 +1,9 @@
1
+ <%= stylesheet_link_tag "devise_safeguard", :media => "all" %>
2
+ <div id="safeguard-form-token">
3
+ <%= form_tag([resource_name, :verify_safeguard], :id => 'devise_safeguard', :class => 'safeguard-form', :method => :post) do %>
4
+ <%= hidden_field_tag(:"#{resource_name}_id", @resource.email) %>
5
+ <%= label_tag :safeguard_token %>
6
+ <%= text_field_tag :safeguard_token, "", :autocomplete => :off, :id => 'safeguard-token' %>
7
+ <%= submit_tag I18n.t('safeguard_token_button', {:scope => 'devise'}), :class => 'button' %>
8
+ <% end %>
9
+ </div>
@@ -0,0 +1,7 @@
1
+ = stylesheet_link_tag "devise_safeguard", :media => "all"
2
+ #safeguard-form-token
3
+ = form_tag([resource_name, :verify_safeguard], :id => 'devise_safeguard', :class => 'safeguard-form', :method => :post) do
4
+ = hidden_field_tag(:"#{resource_name}_id", @resource.email)
5
+ = label_tag :safeguard_token
6
+ = text_field_tag :safeguard_token, "", :autocomplete => :off, :id => 'safeguard-token'
7
+ = submit_tag I18n.t('safeguard_token_button', {:scope => 'devise'}), :class => 'button'
@@ -0,0 +1,5 @@
1
+ pt-BR:
2
+ devise:
3
+ safeguard_form_title: Por favor informe a senha do seu token.
4
+ safeguard_token_button: Enviar senha
5
+ safeguard_token: Token
@@ -0,0 +1,54 @@
1
+ module DeviseSafeguard
2
+ module Controllers
3
+ module Helpers
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ before_filter :is_safeguard_token_needed?, :if => :is_signing_in?
7
+ end
8
+
9
+ def is_signing_in?
10
+ if devise_controller? && signed_in?(resource_name) &&
11
+ self.class == Devise::SessionsController || self.class.ancestors.include?(Devise::SessionsController) &&
12
+ self.action_name == "create"
13
+ return true
14
+ end
15
+
16
+ return false
17
+ end
18
+
19
+ def require_token?
20
+ return false if !signed_in?(resource_name)
21
+ return false if !warden.session(resource_name)[:with_safeguard_authentication]
22
+ return true
23
+ end
24
+
25
+ def is_safeguard_token_needed?
26
+ if require_token?
27
+ # login with 2fa
28
+ id = warden.session(resource_name)[:id]
29
+
30
+ remember_me = (params.fetch(resource_name, {})[:remember_me].to_s == "1")
31
+ return_to = session["#{resource_name}_return_to"]
32
+ warden.logout
33
+ warden.reset_session! # make sure the session resetted
34
+
35
+ session["#{resource_name}_id"] = id
36
+ # this is safe to put in the session because the cookie is signed
37
+ session["#{resource_name}_password_checked"] = true
38
+ session["#{resource_name}_remember_me"] = remember_me
39
+ session["#{resource_name}_return_to"] = return_to if return_to
40
+
41
+ redirect_to verify_safeguard_path_for(resource_name)
42
+ return
43
+ end
44
+ end
45
+
46
+ def verify_safeguard_path_for(resource_or_scope = nil)
47
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
48
+ send("#{scope}_verify_safeguard_path")
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+
@@ -0,0 +1,7 @@
1
+ Warden::Manager.after_authentication do |user, auth, options|
2
+ if user.respond_to?(:with_safeguard_authentication?)
3
+ if auth.session(options[:scope])[:with_safeguard_authentication] = user.with_safeguard_authentication?(auth.request)
4
+ auth.session(options[:scope])[:id] = user.id
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ require 'devise-safeguard/hooks/safeguard_authenticatable'
2
+ module Devise
3
+ module Models
4
+ module SafeguardAuthenticatable
5
+ extend ActiveSupport::Concern
6
+
7
+ def with_safeguard_authentication?(request)
8
+ return true if self.safeguard_enabled
9
+ false
10
+ end
11
+
12
+ module ClassMethods
13
+ Devise::Models.config(self, :safeguard_remember_device)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,7 @@
1
+ module DeviseSafeguard
2
+ class Engine < ::Rails::Engine
3
+ ActiveSupport.on_load(:action_controller) do
4
+ include DeviseSafeguard::Controllers::Helpers
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ protected
4
+
5
+ def devise_safeguard(mapping, controllers)
6
+ match "/#{mapping.path_names[:verify_safeguard]}", :controller => controllers[:devise_safeguard], :action => :GET_verify_safeguard, :as => :verify_safeguard, :via => :get
7
+ match "/#{mapping.path_names[:verify_safeguard]}", :controller => controllers[:devise_safeguard], :action => :POST_verify_safeguard, :as => nil, :via => :post
8
+
9
+ # match "/#{mapping.path_names[:enable_safeguard]}", :controller => controllers[:devise_safeguard], :action => :GET_enable_safeguard, :as => :enable_safeguard, :via => :get
10
+ # match "/#{mapping.path_names[:enable_safeguard]}", :controller => controllers[:devise_safeguard], :action => :POST_enable_safeguard, :as => nil, :via => :post
11
+
12
+ # match "/#{mapping.path_names[:verify_safeguard_installation]}", :controller => controllers[:devise_safeguard], :action => :GET_verify_safeguard_installation, :as => :verify_safeguard_installation, :via => :get
13
+ # match "/#{mapping.path_names[:verify_safeguard_installation]}", :controller => controllers[:devise_safeguard], :action => :POST_verify_safeguard_installation, :as => nil, :via => :post
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,13 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module ActiveRecord
4
+ module Generators
5
+ class DeviseSafeguardGenerator < ActiveRecord::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ def copy_devise_migration
9
+ migration_template "migration.rb", "db/migrate/devise_safeguard_add_to_#{table_name}"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ class DeviseSafeguardAddTo<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ change_table :<%= table_name %> do |t|
4
+ t.datetime :last_sign_in_with_safeguard
5
+ t.boolean :safeguard_enabled, :default => false
6
+ end
7
+
8
+ end
9
+
10
+ def self.down
11
+ change_table :<%= table_name %> do |t|
12
+ t.remove :last_sign_in_with_safeguard, :safeguard_enabled
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,30 @@
1
+ module DeviseSafeguard
2
+ module Generators
3
+ class DeviseSafeguardGenerator < Rails::Generators::NamedBase
4
+
5
+ namespace "devise_safeguard"
6
+
7
+ desc "Add :safeguard_authenticatable directive in the given model, plus accessors. Also generate migration for ActiveRecord"
8
+
9
+ def inject_devise_safeguard_content
10
+ path = File.join("app","models","#{file_path}.rb")
11
+ if File.exists?(path) &&
12
+ !File.read(path).include?("safeguard_authenticatable")
13
+ inject_into_file(path,
14
+ "safeguard_authenticatable, :",
15
+ :after => "devise :")
16
+ end
17
+
18
+ if File.exists?(path) &&
19
+ !File.read(path).include?(":last_sign_in_with_safeguard")
20
+ inject_into_file(path,
21
+ ":last_sign_in_with_safeguard, ",
22
+ :after => "attr_accessible ")
23
+ end
24
+ end
25
+
26
+ hook_for :orm
27
+
28
+ end
29
+ end
30
+ end