mongo_session_store-rails5 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (327) hide show
  1. checksums.yaml +7 -0
  2. data/.bundle/install.log +768 -0
  3. data/.gitignore +10 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +21 -0
  6. data/Gemfile +67 -0
  7. data/README.md +133 -0
  8. data/Rakefile +93 -0
  9. data/lib/mongo_session_store-rails3.rb +1 -0
  10. data/lib/mongo_session_store-rails4.rb +1 -0
  11. data/lib/mongo_session_store-rails5.rb +1 -0
  12. data/lib/mongo_session_store.rb +49 -0
  13. data/lib/mongo_session_store/mongo_mapper_store.rb +22 -0
  14. data/lib/mongo_session_store/mongo_store.rb +83 -0
  15. data/lib/mongo_session_store/mongo_store_base.rb +98 -0
  16. data/lib/mongo_session_store/mongoid_store.rb +57 -0
  17. data/lib/mongo_session_store/version.rb +3 -0
  18. data/mongo_session_store-rails3.gemspec +18 -0
  19. data/mongo_session_store-rails4.gemspec +18 -0
  20. data/mongo_session_store-rails5.gemspec +20 -0
  21. data/perf/benchmark.rb +92 -0
  22. data/release.sh +6 -0
  23. data/spec/integration_with_devise_spec.rb +89 -0
  24. data/spec/mongo_store_base_spec.rb +42 -0
  25. data/spec/rails_3.1_app/.gitignore +5 -0
  26. data/spec/rails_3.1_app/README +261 -0
  27. data/spec/rails_3.1_app/Rakefile +7 -0
  28. data/spec/rails_3.1_app/app/assets/javascripts/application.js +7 -0
  29. data/spec/rails_3.1_app/app/assets/stylesheets/application.css +7 -0
  30. data/spec/rails_3.1_app/app/controllers/application_controller.rb +3 -0
  31. data/spec/rails_3.1_app/app/controllers/home_controller.rb +4 -0
  32. data/spec/rails_3.1_app/app/helpers/application_helper.rb +2 -0
  33. data/spec/rails_3.1_app/app/mailers/.gitkeep +0 -0
  34. data/spec/rails_3.1_app/app/models/.gitkeep +0 -0
  35. data/spec/rails_3.1_app/app/models/user.rb +6 -0
  36. data/spec/rails_3.1_app/app/views/devise/confirmations/new.html.erb +12 -0
  37. data/spec/rails_3.1_app/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  38. data/spec/rails_3.1_app/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  39. data/spec/rails_3.1_app/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  40. data/spec/rails_3.1_app/app/views/devise/passwords/edit.html.erb +16 -0
  41. data/spec/rails_3.1_app/app/views/devise/passwords/new.html.erb +12 -0
  42. data/spec/rails_3.1_app/app/views/devise/registrations/edit.html.erb +25 -0
  43. data/spec/rails_3.1_app/app/views/devise/registrations/new.html.erb +18 -0
  44. data/spec/rails_3.1_app/app/views/devise/sessions/new.html.erb +17 -0
  45. data/spec/rails_3.1_app/app/views/devise/shared/_links.erb +25 -0
  46. data/spec/rails_3.1_app/app/views/devise/unlocks/new.html.erb +12 -0
  47. data/spec/rails_3.1_app/app/views/home/index.html.erb +10 -0
  48. data/spec/rails_3.1_app/app/views/layouts/application.html.erb +15 -0
  49. data/spec/rails_3.1_app/config.ru +4 -0
  50. data/spec/rails_3.1_app/config/application.rb +47 -0
  51. data/spec/rails_3.1_app/config/boot.rb +6 -0
  52. data/spec/rails_3.1_app/config/database.yml +11 -0
  53. data/spec/rails_3.1_app/config/environment.rb +5 -0
  54. data/spec/rails_3.1_app/config/environments/development.rb +27 -0
  55. data/spec/rails_3.1_app/config/environments/production.rb +54 -0
  56. data/spec/rails_3.1_app/config/environments/test.rb +39 -0
  57. data/spec/rails_3.1_app/config/initializers/backtrace_silencers.rb +7 -0
  58. data/spec/rails_3.1_app/config/initializers/devise.rb +201 -0
  59. data/spec/rails_3.1_app/config/initializers/inflections.rb +10 -0
  60. data/spec/rails_3.1_app/config/initializers/mime_types.rb +5 -0
  61. data/spec/rails_3.1_app/config/initializers/secret_token.rb +7 -0
  62. data/spec/rails_3.1_app/config/initializers/session_store.rb +9 -0
  63. data/spec/rails_3.1_app/config/initializers/wrap_parameters.rb +12 -0
  64. data/spec/rails_3.1_app/config/locales/devise.en.yml +55 -0
  65. data/spec/rails_3.1_app/config/locales/en.yml +5 -0
  66. data/spec/rails_3.1_app/config/mongo.yml +18 -0
  67. data/spec/rails_3.1_app/config/mongoid.yml +13 -0
  68. data/spec/rails_3.1_app/config/routes.rb +4 -0
  69. data/spec/rails_3.1_app/db/migrate/20120222195914_create_users_table.rb +12 -0
  70. data/spec/rails_3.1_app/db/schema.rb +20 -0
  71. data/spec/rails_3.1_app/lib/tasks/.gitkeep +0 -0
  72. data/spec/rails_3.1_app/log/.gitkeep +0 -0
  73. data/spec/rails_3.1_app/public/404.html +26 -0
  74. data/spec/rails_3.1_app/public/422.html +26 -0
  75. data/spec/rails_3.1_app/public/500.html +26 -0
  76. data/spec/rails_3.1_app/public/favicon.ico +0 -0
  77. data/spec/rails_3.1_app/public/robots.txt +5 -0
  78. data/spec/rails_3.1_app/script/rails +6 -0
  79. data/spec/rails_3.1_app/vendor/assets/stylesheets/.gitkeep +0 -0
  80. data/spec/rails_3.1_app/vendor/plugins/.gitkeep +0 -0
  81. data/spec/rails_3.2_app/.gitignore +5 -0
  82. data/spec/rails_3.2_app/README +261 -0
  83. data/spec/rails_3.2_app/Rakefile +7 -0
  84. data/spec/rails_3.2_app/app/assets/javascripts/application.js +7 -0
  85. data/spec/rails_3.2_app/app/assets/stylesheets/application.css +7 -0
  86. data/spec/rails_3.2_app/app/controllers/application_controller.rb +3 -0
  87. data/spec/rails_3.2_app/app/controllers/home_controller.rb +4 -0
  88. data/spec/rails_3.2_app/app/helpers/application_helper.rb +2 -0
  89. data/spec/rails_3.2_app/app/mailers/.gitkeep +0 -0
  90. data/spec/rails_3.2_app/app/models/.gitkeep +0 -0
  91. data/spec/rails_3.2_app/app/models/user.rb +6 -0
  92. data/spec/rails_3.2_app/app/views/devise/confirmations/new.html.erb +12 -0
  93. data/spec/rails_3.2_app/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  94. data/spec/rails_3.2_app/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  95. data/spec/rails_3.2_app/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  96. data/spec/rails_3.2_app/app/views/devise/passwords/edit.html.erb +16 -0
  97. data/spec/rails_3.2_app/app/views/devise/passwords/new.html.erb +12 -0
  98. data/spec/rails_3.2_app/app/views/devise/registrations/edit.html.erb +25 -0
  99. data/spec/rails_3.2_app/app/views/devise/registrations/new.html.erb +18 -0
  100. data/spec/rails_3.2_app/app/views/devise/sessions/new.html.erb +17 -0
  101. data/spec/rails_3.2_app/app/views/devise/shared/_links.erb +25 -0
  102. data/spec/rails_3.2_app/app/views/devise/unlocks/new.html.erb +12 -0
  103. data/spec/rails_3.2_app/app/views/home/index.html.erb +10 -0
  104. data/spec/rails_3.2_app/app/views/layouts/application.html.erb +15 -0
  105. data/spec/rails_3.2_app/config.ru +4 -0
  106. data/spec/rails_3.2_app/config/application.rb +47 -0
  107. data/spec/rails_3.2_app/config/boot.rb +6 -0
  108. data/spec/rails_3.2_app/config/database.yml +11 -0
  109. data/spec/rails_3.2_app/config/environment.rb +5 -0
  110. data/spec/rails_3.2_app/config/environments/development.rb +27 -0
  111. data/spec/rails_3.2_app/config/environments/production.rb +54 -0
  112. data/spec/rails_3.2_app/config/environments/test.rb +39 -0
  113. data/spec/rails_3.2_app/config/initializers/backtrace_silencers.rb +7 -0
  114. data/spec/rails_3.2_app/config/initializers/devise.rb +203 -0
  115. data/spec/rails_3.2_app/config/initializers/inflections.rb +10 -0
  116. data/spec/rails_3.2_app/config/initializers/mime_types.rb +5 -0
  117. data/spec/rails_3.2_app/config/initializers/secret_token.rb +7 -0
  118. data/spec/rails_3.2_app/config/initializers/session_store.rb +9 -0
  119. data/spec/rails_3.2_app/config/initializers/wrap_parameters.rb +12 -0
  120. data/spec/rails_3.2_app/config/locales/devise.en.yml +55 -0
  121. data/spec/rails_3.2_app/config/locales/en.yml +5 -0
  122. data/spec/rails_3.2_app/config/mongo.yml +18 -0
  123. data/spec/rails_3.2_app/config/mongoid.yml +13 -0
  124. data/spec/rails_3.2_app/config/routes.rb +4 -0
  125. data/spec/rails_3.2_app/db/migrate/20120222195914_create_users_table.rb +12 -0
  126. data/spec/rails_3.2_app/db/schema.rb +20 -0
  127. data/spec/rails_3.2_app/lib/tasks/.gitkeep +0 -0
  128. data/spec/rails_3.2_app/log/.gitkeep +0 -0
  129. data/spec/rails_3.2_app/public/404.html +26 -0
  130. data/spec/rails_3.2_app/public/422.html +26 -0
  131. data/spec/rails_3.2_app/public/500.html +26 -0
  132. data/spec/rails_3.2_app/public/favicon.ico +0 -0
  133. data/spec/rails_3.2_app/public/robots.txt +5 -0
  134. data/spec/rails_3.2_app/script/rails +6 -0
  135. data/spec/rails_3.2_app/vendor/assets/stylesheets/.gitkeep +0 -0
  136. data/spec/rails_3.2_app/vendor/plugins/.gitkeep +0 -0
  137. data/spec/rails_4.0_app/.gitignore +16 -0
  138. data/spec/rails_4.0_app/Rakefile +6 -0
  139. data/spec/rails_4.0_app/app/assets/images/.keep +0 -0
  140. data/spec/rails_4.0_app/app/assets/javascripts/application.js +13 -0
  141. data/spec/rails_4.0_app/app/assets/stylesheets/application.css +13 -0
  142. data/spec/rails_4.0_app/app/controllers/application_controller.rb +5 -0
  143. data/spec/rails_4.0_app/app/controllers/concerns/.keep +0 -0
  144. data/spec/rails_4.0_app/app/controllers/home_controller.rb +4 -0
  145. data/spec/rails_4.0_app/app/helpers/application_helper.rb +2 -0
  146. data/spec/rails_4.0_app/app/mailers/.keep +0 -0
  147. data/spec/rails_4.0_app/app/models/.keep +0 -0
  148. data/spec/rails_4.0_app/app/models/concerns/.keep +0 -0
  149. data/spec/rails_4.0_app/app/models/user.rb +5 -0
  150. data/spec/rails_4.0_app/app/views/devise/confirmations/new.html.erb +12 -0
  151. data/spec/rails_4.0_app/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  152. data/spec/rails_4.0_app/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  153. data/spec/rails_4.0_app/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  154. data/spec/rails_4.0_app/app/views/devise/passwords/edit.html.erb +16 -0
  155. data/spec/rails_4.0_app/app/views/devise/passwords/new.html.erb +12 -0
  156. data/spec/rails_4.0_app/app/views/devise/registrations/edit.html.erb +29 -0
  157. data/spec/rails_4.0_app/app/views/devise/registrations/new.html.erb +18 -0
  158. data/spec/rails_4.0_app/app/views/devise/sessions/new.html.erb +17 -0
  159. data/spec/rails_4.0_app/app/views/devise/shared/_links.erb +25 -0
  160. data/spec/rails_4.0_app/app/views/devise/unlocks/new.html.erb +12 -0
  161. data/spec/rails_4.0_app/app/views/home/index.html.erb +10 -0
  162. data/spec/rails_4.0_app/app/views/layouts/application.html.erb +17 -0
  163. data/spec/rails_4.0_app/bin/bundle +3 -0
  164. data/spec/rails_4.0_app/bin/rails +4 -0
  165. data/spec/rails_4.0_app/bin/rake +4 -0
  166. data/spec/rails_4.0_app/config.ru +4 -0
  167. data/spec/rails_4.0_app/config/application.rb +26 -0
  168. data/spec/rails_4.0_app/config/boot.rb +4 -0
  169. data/spec/rails_4.0_app/config/database.yml +11 -0
  170. data/spec/rails_4.0_app/config/environment.rb +5 -0
  171. data/spec/rails_4.0_app/config/environments/development.rb +29 -0
  172. data/spec/rails_4.0_app/config/environments/production.rb +80 -0
  173. data/spec/rails_4.0_app/config/environments/test.rb +36 -0
  174. data/spec/rails_4.0_app/config/initializers/backtrace_silencers.rb +7 -0
  175. data/spec/rails_4.0_app/config/initializers/devise.rb +254 -0
  176. data/spec/rails_4.0_app/config/initializers/filter_parameter_logging.rb +4 -0
  177. data/spec/rails_4.0_app/config/initializers/inflections.rb +16 -0
  178. data/spec/rails_4.0_app/config/initializers/mime_types.rb +5 -0
  179. data/spec/rails_4.0_app/config/initializers/secret_token.rb +12 -0
  180. data/spec/rails_4.0_app/config/initializers/session_store.rb +5 -0
  181. data/spec/rails_4.0_app/config/initializers/wrap_parameters.rb +14 -0
  182. data/spec/rails_4.0_app/config/locales/devise.en.yml +59 -0
  183. data/spec/rails_4.0_app/config/locales/en.yml +23 -0
  184. data/spec/rails_4.0_app/config/mongo.yml +11 -0
  185. data/spec/rails_4.0_app/config/mongoid.yml +13 -0
  186. data/spec/rails_4.0_app/config/routes.rb +4 -0
  187. data/spec/rails_4.0_app/db/migrate/20140301171212_add_devise_users.rb +11 -0
  188. data/spec/rails_4.0_app/db/schema.rb +25 -0
  189. data/spec/rails_4.0_app/db/seeds.rb +7 -0
  190. data/spec/rails_4.0_app/lib/assets/.keep +0 -0
  191. data/spec/rails_4.0_app/lib/tasks/.keep +0 -0
  192. data/spec/rails_4.0_app/log/.keep +0 -0
  193. data/spec/rails_4.0_app/public/404.html +58 -0
  194. data/spec/rails_4.0_app/public/422.html +58 -0
  195. data/spec/rails_4.0_app/public/500.html +57 -0
  196. data/spec/rails_4.0_app/public/favicon.ico +0 -0
  197. data/spec/rails_4.0_app/public/robots.txt +5 -0
  198. data/spec/rails_4.1_app/.gitignore +16 -0
  199. data/spec/rails_4.1_app/Rakefile +6 -0
  200. data/spec/rails_4.1_app/app/assets/images/.keep +0 -0
  201. data/spec/rails_4.1_app/app/assets/javascripts/application.js +13 -0
  202. data/spec/rails_4.1_app/app/assets/stylesheets/application.css +15 -0
  203. data/spec/rails_4.1_app/app/controllers/application_controller.rb +5 -0
  204. data/spec/rails_4.1_app/app/controllers/concerns/.keep +0 -0
  205. data/spec/rails_4.1_app/app/controllers/home_controller.rb +4 -0
  206. data/spec/rails_4.1_app/app/helpers/application_helper.rb +2 -0
  207. data/spec/rails_4.1_app/app/mailers/.keep +0 -0
  208. data/spec/rails_4.1_app/app/models/.keep +0 -0
  209. data/spec/rails_4.1_app/app/models/concerns/.keep +0 -0
  210. data/spec/rails_4.1_app/app/models/user.rb +5 -0
  211. data/spec/rails_4.1_app/app/views/devise/confirmations/new.html.erb +12 -0
  212. data/spec/rails_4.1_app/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  213. data/spec/rails_4.1_app/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  214. data/spec/rails_4.1_app/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  215. data/spec/rails_4.1_app/app/views/devise/passwords/edit.html.erb +16 -0
  216. data/spec/rails_4.1_app/app/views/devise/passwords/new.html.erb +12 -0
  217. data/spec/rails_4.1_app/app/views/devise/registrations/edit.html.erb +29 -0
  218. data/spec/rails_4.1_app/app/views/devise/registrations/new.html.erb +18 -0
  219. data/spec/rails_4.1_app/app/views/devise/sessions/new.html.erb +17 -0
  220. data/spec/rails_4.1_app/app/views/devise/shared/_links.erb +25 -0
  221. data/spec/rails_4.1_app/app/views/devise/unlocks/new.html.erb +12 -0
  222. data/spec/rails_4.1_app/app/views/home/index.html.erb +10 -0
  223. data/spec/rails_4.1_app/app/views/layouts/application.html.erb +17 -0
  224. data/spec/rails_4.1_app/bin/bundle +3 -0
  225. data/spec/rails_4.1_app/bin/rails +8 -0
  226. data/spec/rails_4.1_app/bin/rake +8 -0
  227. data/spec/rails_4.1_app/bin/spring +18 -0
  228. data/spec/rails_4.1_app/config.ru +4 -0
  229. data/spec/rails_4.1_app/config/application.rb +23 -0
  230. data/spec/rails_4.1_app/config/boot.rb +4 -0
  231. data/spec/rails_4.1_app/config/database.yml +11 -0
  232. data/spec/rails_4.1_app/config/environment.rb +5 -0
  233. data/spec/rails_4.1_app/config/environments/development.rb +37 -0
  234. data/spec/rails_4.1_app/config/environments/production.rb +83 -0
  235. data/spec/rails_4.1_app/config/environments/test.rb +39 -0
  236. data/spec/rails_4.1_app/config/initializers/backtrace_silencers.rb +7 -0
  237. data/spec/rails_4.1_app/config/initializers/cookies_serializer.rb +3 -0
  238. data/spec/rails_4.1_app/config/initializers/devise.rb +254 -0
  239. data/spec/rails_4.1_app/config/initializers/filter_parameter_logging.rb +4 -0
  240. data/spec/rails_4.1_app/config/initializers/inflections.rb +16 -0
  241. data/spec/rails_4.1_app/config/initializers/mime_types.rb +5 -0
  242. data/spec/rails_4.1_app/config/initializers/session_store.rb +5 -0
  243. data/spec/rails_4.1_app/config/initializers/wrap_parameters.rb +14 -0
  244. data/spec/rails_4.1_app/config/locales/devise.en.yml +59 -0
  245. data/spec/rails_4.1_app/config/locales/en.yml +23 -0
  246. data/spec/rails_4.1_app/config/mongo.yml +11 -0
  247. data/spec/rails_4.1_app/config/mongoid.yml +13 -0
  248. data/spec/rails_4.1_app/config/routes.rb +4 -0
  249. data/spec/rails_4.1_app/config/secrets.yml +22 -0
  250. data/spec/rails_4.1_app/db/migrate/20140301171212_add_devise_users.rb +11 -0
  251. data/spec/rails_4.1_app/db/schema.rb +25 -0
  252. data/spec/rails_4.1_app/db/seeds.rb +7 -0
  253. data/spec/rails_4.1_app/lib/assets/.keep +0 -0
  254. data/spec/rails_4.1_app/lib/tasks/.keep +0 -0
  255. data/spec/rails_4.1_app/log/.keep +0 -0
  256. data/spec/rails_4.1_app/public/404.html +67 -0
  257. data/spec/rails_4.1_app/public/422.html +67 -0
  258. data/spec/rails_4.1_app/public/500.html +66 -0
  259. data/spec/rails_4.1_app/public/favicon.ico +0 -0
  260. data/spec/rails_4.1_app/public/robots.txt +5 -0
  261. data/spec/rails_4.2_app/.gitignore +17 -0
  262. data/spec/rails_4.2_app/Rakefile +6 -0
  263. data/spec/rails_4.2_app/app/assets/images/.keep +0 -0
  264. data/spec/rails_4.2_app/app/assets/javascripts/application.js +13 -0
  265. data/spec/rails_4.2_app/app/assets/stylesheets/application.css +15 -0
  266. data/spec/rails_4.2_app/app/controllers/application_controller.rb +5 -0
  267. data/spec/rails_4.2_app/app/controllers/concerns/.keep +0 -0
  268. data/spec/rails_4.2_app/app/controllers/home_controller.rb +4 -0
  269. data/spec/rails_4.2_app/app/helpers/application_helper.rb +2 -0
  270. data/spec/rails_4.2_app/app/mailers/.keep +0 -0
  271. data/spec/rails_4.2_app/app/models/.keep +0 -0
  272. data/spec/rails_4.2_app/app/models/concerns/.keep +0 -0
  273. data/spec/rails_4.2_app/app/models/user.rb +5 -0
  274. data/spec/rails_4.2_app/app/views/devise/confirmations/new.html.erb +12 -0
  275. data/spec/rails_4.2_app/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  276. data/spec/rails_4.2_app/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  277. data/spec/rails_4.2_app/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  278. data/spec/rails_4.2_app/app/views/devise/passwords/edit.html.erb +16 -0
  279. data/spec/rails_4.2_app/app/views/devise/passwords/new.html.erb +12 -0
  280. data/spec/rails_4.2_app/app/views/devise/registrations/edit.html.erb +29 -0
  281. data/spec/rails_4.2_app/app/views/devise/registrations/new.html.erb +18 -0
  282. data/spec/rails_4.2_app/app/views/devise/sessions/new.html.erb +17 -0
  283. data/spec/rails_4.2_app/app/views/devise/shared/_links.erb +25 -0
  284. data/spec/rails_4.2_app/app/views/devise/unlocks/new.html.erb +12 -0
  285. data/spec/rails_4.2_app/app/views/home/index.html.erb +10 -0
  286. data/spec/rails_4.2_app/app/views/layouts/application.html.erb +17 -0
  287. data/spec/rails_4.2_app/bin/bundle +3 -0
  288. data/spec/rails_4.2_app/bin/rails +8 -0
  289. data/spec/rails_4.2_app/bin/rake +8 -0
  290. data/spec/rails_4.2_app/bin/setup +29 -0
  291. data/spec/rails_4.2_app/bin/spring +15 -0
  292. data/spec/rails_4.2_app/config.ru +4 -0
  293. data/spec/rails_4.2_app/config/application.rb +26 -0
  294. data/spec/rails_4.2_app/config/boot.rb +3 -0
  295. data/spec/rails_4.2_app/config/database.yml +11 -0
  296. data/spec/rails_4.2_app/config/environment.rb +5 -0
  297. data/spec/rails_4.2_app/config/environments/development.rb +41 -0
  298. data/spec/rails_4.2_app/config/environments/production.rb +79 -0
  299. data/spec/rails_4.2_app/config/environments/test.rb +42 -0
  300. data/spec/rails_4.2_app/config/initializers/assets.rb +11 -0
  301. data/spec/rails_4.2_app/config/initializers/backtrace_silencers.rb +7 -0
  302. data/spec/rails_4.2_app/config/initializers/cookies_serializer.rb +3 -0
  303. data/spec/rails_4.2_app/config/initializers/devise.rb +254 -0
  304. data/spec/rails_4.2_app/config/initializers/filter_parameter_logging.rb +4 -0
  305. data/spec/rails_4.2_app/config/initializers/inflections.rb +16 -0
  306. data/spec/rails_4.2_app/config/initializers/mime_types.rb +4 -0
  307. data/spec/rails_4.2_app/config/initializers/session_store.rb +5 -0
  308. data/spec/rails_4.2_app/config/initializers/wrap_parameters.rb +14 -0
  309. data/spec/rails_4.2_app/config/locales/en.yml +23 -0
  310. data/spec/rails_4.2_app/config/mongo.yml +11 -0
  311. data/spec/rails_4.2_app/config/mongoid.yml +13 -0
  312. data/spec/rails_4.2_app/config/routes.rb +4 -0
  313. data/spec/rails_4.2_app/config/secrets.yml +22 -0
  314. data/spec/rails_4.2_app/db/migrate/20140301171212_add_devise_users.rb +11 -0
  315. data/spec/rails_4.2_app/db/schema.rb +25 -0
  316. data/spec/rails_4.2_app/db/seeds.rb +7 -0
  317. data/spec/rails_4.2_app/lib/assets/.keep +0 -0
  318. data/spec/rails_4.2_app/lib/tasks/.keep +0 -0
  319. data/spec/rails_4.2_app/log/.keep +0 -0
  320. data/spec/rails_4.2_app/public/404.html +67 -0
  321. data/spec/rails_4.2_app/public/422.html +67 -0
  322. data/spec/rails_4.2_app/public/500.html +66 -0
  323. data/spec/rails_4.2_app/public/favicon.ico +0 -0
  324. data/spec/rails_4.2_app/public/robots.txt +5 -0
  325. data/spec/rails_helper.rb +47 -0
  326. data/spec/spec_helper.rb +5 -0
  327. metadata +409 -0
@@ -0,0 +1,98 @@
1
+ require 'action_dispatch/middleware/session/abstract_store'
2
+
3
+ module ActionDispatch
4
+ module Session
5
+ class MongoStoreBase < AbstractStore
6
+
7
+ SESSION_RECORD_KEY = Rack::RACK_SESSION
8
+ begin
9
+ ENV_SESSION_OPTIONS_KEY = Rack::RACK_SESSION_OPTIONS
10
+ rescue NameError
11
+ # Rack 1.2.x has access to the ENV_SESSION_OPTIONS_KEY
12
+ end
13
+
14
+ def self.session_class
15
+ self::Session
16
+ end
17
+
18
+ private
19
+ def session_class
20
+ self.class.session_class
21
+ end
22
+
23
+ def generate_sid
24
+ # 20 random bytes in url-safe base64
25
+ SecureRandom.base64(20).gsub('=','').gsub('+','-').gsub('/','_')
26
+ end
27
+
28
+ def get_session(env, sid)
29
+ sid, record = find_or_initialize_session(sid)
30
+ env[SESSION_RECORD_KEY] = record
31
+ [sid, unpack(record.data)]
32
+ end
33
+
34
+ def find_session(env, sid)
35
+ get_session(env, sid)
36
+ end
37
+
38
+ def set_session(env, sid, session_data, options = {})
39
+ id, record = get_session_record(env, sid)
40
+ record.data = pack(session_data)
41
+ # Rack spec dictates that set_session should return true or false
42
+ # depending on whether or not the session was saved or not.
43
+ # However, ActionPack seems to want a session id instead.
44
+ record.save ? id : false
45
+ end
46
+
47
+ def write_session(env, sid, session_data, options = {})
48
+ set_session(env, sid, session_data, options)
49
+ end
50
+
51
+
52
+ def find_or_initialize_session(sid)
53
+ session = (sid && session_class.where(:_id => sid).first) || session_class.new(:_id => generate_sid)
54
+ [session._id, session]
55
+ end
56
+
57
+ def get_session_record(env, sid)
58
+ if env.env[ENV_SESSION_OPTIONS_KEY][:id].nil? || !env[SESSION_RECORD_KEY]
59
+ sid, env[SESSION_RECORD_KEY] = find_or_initialize_session(sid)
60
+ end
61
+
62
+ [sid, env[SESSION_RECORD_KEY]]
63
+ end
64
+
65
+ def delete_session(env, sid, options)
66
+ destroy_session(env, sid, options)
67
+ end
68
+
69
+ def destroy_session(env, sid, options)
70
+ unless options[:renew]
71
+ destroy(env)
72
+ generate_sid if !options[:drop] or options[:renew]
73
+ else
74
+ sid
75
+ end
76
+ end
77
+
78
+ def destroy(env)
79
+ if sid = current_session_id(env)
80
+ _, record = get_session_record(env, sid)
81
+ record.destroy
82
+ env[SESSION_RECORD_KEY] = nil
83
+ end
84
+ end
85
+
86
+ def pack(data)
87
+ Marshal.dump(data)
88
+ end
89
+
90
+ def unpack(packed)
91
+ return nil unless packed
92
+ data = packed.respond_to?(:data) ? packed.data : packed.to_s
93
+ Marshal.load(StringIO.new(data))
94
+ end
95
+
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,57 @@
1
+ require 'mongoid'
2
+ require 'mongo_session_store/mongo_store_base'
3
+
4
+ module ActionDispatch
5
+ module Session
6
+ class MongoidStore < MongoStoreBase
7
+ BINARY_CLASS = defined?(Moped::BSON::Binary) ? Moped::BSON::Binary : BSON::Binary
8
+
9
+ class Session
10
+ include Mongoid::Document
11
+ include Mongoid::Timestamps
12
+
13
+ store_in :collection => MongoSessionStore.collection_name
14
+
15
+ if Mongoid::Fields::Validators::Macro::OPTIONS.include? :overwrite
16
+ field :_id, :type => String, :overwrite => true
17
+ else
18
+ field :_id, :type => String
19
+ end
20
+ field :data, :type => BINARY_CLASS, :default => -> { marshaled_binary({}) }
21
+ attr_accessible :_id, :data if respond_to?(:attr_accessible)
22
+
23
+ def marshaled_binary(data)
24
+ self.class.marshaled_binary(data)
25
+ end
26
+
27
+ def self.marshaled_binary(data)
28
+ if BINARY_CLASS.to_s == 'BSON::Binary'
29
+ BSON::Binary.new(Marshal.dump(data), :generic)
30
+ else
31
+ Moped::BSON::Binary.new(:generic, Marshal.dump(data))
32
+ end
33
+ end
34
+ end
35
+
36
+ private
37
+ def pack(data)
38
+ session_class.marshaled_binary(data)
39
+ end
40
+
41
+ def unpack(packed)
42
+ return nil unless packed
43
+ Marshal.load(extract_data(packed))
44
+ end
45
+
46
+ def extract_data(packed)
47
+ if packed.class.to_s == 'BSON::Binary'
48
+ packed.data
49
+ else
50
+ packed.to_s
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ MongoidStore = ActionDispatch::Session::MongoidStore
@@ -0,0 +1,3 @@
1
+ module MongoSessionStore
2
+ VERSION = "7.0.0"
3
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../lib/mongo_session_store/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = File.basename(__FILE__).gsub(".gemspec", "")
5
+ s.version = MongoSessionStore::VERSION
6
+
7
+ s.authors = ["Brian Hempel", "Nicolas M\303\251rouze", "Tony Pitale", "Chris Brickley"]
8
+ s.email = ["plasticchicken@gmail.com"]
9
+ s.files = `git ls-files`.split("\n")
10
+ s.test_files = `git ls-files -- {test,spec,features,perf}/*`.split("\n")
11
+ s.homepage = "http://github.com/brianhempel/mongo_session_store"
12
+ s.license = "MIT"
13
+ s.require_paths = ["lib"]
14
+ s.rubygems_version = "1.3.7"
15
+ s.summary = "Rails session stores for MongoMapper, Mongoid, or any other ODM. Rails 3.1, 3.2, 4.0, 4.1, and 4.2 compatible."
16
+
17
+ s.add_dependency "actionpack", ">= 3.1"
18
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../lib/mongo_session_store/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = File.basename(__FILE__).gsub(".gemspec", "")
5
+ s.version = MongoSessionStore::VERSION
6
+
7
+ s.authors = ["Brian Hempel", "Nicolas M\303\251rouze", "Tony Pitale", "Chris Brickley"]
8
+ s.email = ["plasticchicken@gmail.com"]
9
+ s.files = `git ls-files`.split("\n")
10
+ s.test_files = `git ls-files -- {test,spec,features,perf}/*`.split("\n")
11
+ s.homepage = "http://github.com/brianhempel/mongo_session_store"
12
+ s.license = "MIT"
13
+ s.require_paths = ["lib"]
14
+ s.rubygems_version = "1.3.7"
15
+ s.summary = "Rails session stores for MongoMapper, Mongoid, or any other ODM. Rails 3.1, 3.2, 4.0, 4.1, and 4.2 compatible."
16
+
17
+ s.add_dependency "actionpack", ">= 3.1"
18
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path('../lib/mongo_session_store/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = File.basename(__FILE__).gsub(".gemspec", "")
5
+ s.version = MongoSessionStore::VERSION
6
+
7
+ s.authors = ["Alexander Kiseliev", "Brian Hempel", "Nicolas M\303\251rouze", "Tony Pitale", "Chris Brickley"]
8
+ s.email = ["i43ack@gmail.com", "plasticchicken@gmail.com"]
9
+ s.files = `git ls-files`.split("\n")
10
+ s.test_files = `git ls-files -- {test,spec,features,perf}/*`.split("\n")
11
+ s.homepage = "https://github.com/ack43/mongo_session_store"
12
+ s.license = "MIT"
13
+ s.require_paths = ["lib"]
14
+ s.rubygems_version = "1.3.7"
15
+ s.summary = "Rails session stores for MongoMapper, Mongoid, or any other ODM. Rails 5.0 compatible."
16
+
17
+ s.add_dependency "actionpack", ">= 3.1"
18
+
19
+ s.add_dependency 'rails', ['>=5.0', "<6.0"]
20
+ end
data/perf/benchmark.rb ADDED
@@ -0,0 +1,92 @@
1
+ require 'benchmark'
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ require 'action_dispatch'
5
+ require File.expand_path('../../lib/mongo_session_store-rails3', __FILE__)
6
+
7
+ MongoMapper.database = "test_session_stores"
8
+ # get around Mongoid's unnecessary "requires MongoDB 2.0.0" error which is NOT triggered when loading from mongo.yml!
9
+ Mongoid.config.from_hash('database' => "test_session_stores", 'logger' => false)
10
+
11
+ RUNS = 2000
12
+
13
+ def benchmark(test_name, &block)
14
+ sleep 2 # cool off for my poor laptop
15
+ time = Benchmark.realtime do
16
+ RUNS.times do
17
+ yield
18
+ end
19
+ end
20
+ puts "#{(time/RUNS*100_000).round / 100.0}ms per #{test_name}"
21
+ end
22
+
23
+ def benchmark_store(store)
24
+ collection = store.class.session_class.collection
25
+ collection.remove
26
+
27
+ large_session = {
28
+ :something => "not nothing",
29
+ :left => "not right",
30
+ :welcome => "not despised",
31
+ :visits => [
32
+ "http://www.google.com",
33
+ "localhost:3000",
34
+ "http://localhost:3000/increment_session",
35
+ "http://www.iso.org/iso/country_codes/iso_3166_code_lists/iso-3166-1_decoding_table.htm",
36
+ "http://www.geonames.org/search.html?q=2303+australia&country="
37
+ ],
38
+ :one_k_of_data => "a"*1024,
39
+ :another_k => "b"*1024,
40
+ :more_data => [5]*500,
41
+ :too_much_data_for_a_cookie => "c"*8000,
42
+ :a_bunch_of_floats_in_embedded_docs => [{:float_a => 3.141, :float_b => -1.1}]*100
43
+ }
44
+
45
+ ids = []
46
+
47
+ env = {
48
+ 'rack.session' => large_session,
49
+ 'rack.session.options' => { :id => store.send(:generate_sid) }
50
+ }
51
+ benchmark "session save" do
52
+ id = store.send(:generate_sid)
53
+ ids << id
54
+ store.send(:set_session, env.merge({'rack.session.options' => { :id => id }}), id, env['rack.session'])
55
+ # store.send(:commit_session, env.merge({'rack.session.options' => { :id => ids.last }}), 200, {}, [])
56
+ end
57
+
58
+ ids.shuffle!
59
+
60
+ env = {
61
+ 'rack.request.cookie_string' => "",
62
+ 'HTTP_COOKIE' => "",
63
+ 'rack.request.cookie_hash' => { '_session_id' => store.class.session_class.last._id }
64
+ }
65
+ benchmark "session load" do
66
+ id = ids.pop
67
+ local_env = env.merge({'rack.request.cookie_hash' => { '_session_id' => id }})
68
+ # store.send(:prepare_session, local_env)
69
+ sid, data = store.send(:get_session, local_env, id)
70
+ # something = local_env['rack.session']["something"] # trigger the load
71
+ raise data.inspect unless data[:something] == "not nothing" && data[:a_bunch_of_floats_in_embedded_docs][0] == {:float_a => 3.141, :float_b => -1.1}
72
+ end
73
+
74
+ stats = collection.stats
75
+ puts " Total Size: #{stats['size']}"
76
+ puts " Object count: #{stats['count']}"
77
+ puts " Average object size: #{stats['avgObjSize']}"
78
+ puts " Index sizes: #{stats['indexSizes'].inspect}"
79
+ end
80
+
81
+ mongo_mapper_store = MongoMapperStore.new(nil)
82
+ mongoid_store = MongoidStore.new(nil)
83
+ mongo_store = MongoStore.new(nil)
84
+
85
+ puts "MongoMapperStore..."
86
+ benchmark_store(mongo_mapper_store)
87
+
88
+ puts "MongoidStore..."
89
+ benchmark_store(mongoid_store)
90
+
91
+ puts "MongoStore..."
92
+ benchmark_store(mongo_store)
data/release.sh ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/bash
2
+ bundle update
3
+ git add --all .
4
+ git commit -am "${*:1}"
5
+ git push
6
+ rake release
@@ -0,0 +1,89 @@
1
+ require 'rails_helper'
2
+
3
+ describe Devise::SessionsController do
4
+ def create_user
5
+ post_data = {
6
+ 'user[email]' => 'person@example.com',
7
+ 'user[password]' => 'secret',
8
+ 'user[password_confirmation]' => 'secret'
9
+ }
10
+ post '/users', post_data
11
+ end
12
+
13
+ def login
14
+ post_data = {
15
+ 'user[email]' => 'person@example.com',
16
+ 'user[password]' => 'secret',
17
+ 'user[password_confirmation]' => 'secret'
18
+ }
19
+ post '/users/sign_in', post_data
20
+ end
21
+
22
+ def logout
23
+ delete '/users/sign_out'
24
+ end
25
+
26
+ def i_should_be_logged_in
27
+ controller.user_signed_in?.should be_true
28
+ get '/'
29
+ response.body.squish.should =~ /You are logged in as person@example.com/
30
+ end
31
+
32
+ def i_should_not_be_logged_in
33
+ controller.user_signed_in?.should be_false
34
+ get '/'
35
+ response.body.squish.should =~ /You are logged out/
36
+ end
37
+
38
+ it "does not explode" do
39
+ end
40
+
41
+ it "allows user creation" do
42
+ User.count.should == 0
43
+ create_user
44
+ response.status.should == 302
45
+ get response.redirect_url
46
+ User.count.should == 1
47
+ response.body.squish.should =~ /You are logged in as person@example.com/
48
+ response.body.squish.should =~ /You have signed up successfully/
49
+ end
50
+
51
+ it "allows user logout" do
52
+ create_user
53
+ i_should_be_logged_in
54
+ logout
55
+ response.status.should == 302
56
+ i_should_not_be_logged_in
57
+ response.body.squish.should =~ /Signed out successfully/
58
+ end
59
+
60
+ it "allows user login" do
61
+ create_user
62
+ logout
63
+ i_should_not_be_logged_in
64
+ login
65
+ response.status.should == 302
66
+ i_should_be_logged_in
67
+ response.body.squish.should =~ /Signed in successfully/
68
+ end
69
+
70
+ it "uses the right session store class" do
71
+ store = Rails.application.config.session_store
72
+ store.session_class.to_s.should == "ActionDispatch::Session::#{ENV["MONGO_SESSION_STORE_ORM"].camelize}Store::Session"
73
+ end
74
+
75
+ it "stores the session in the sessions collection" do
76
+ collection = db["sessions"]
77
+ collection.find.count.should == 0
78
+ create_user
79
+ collection.find.count.should == 1
80
+ end
81
+
82
+ it "allows renaming of the collection that stores the sessions" do
83
+ collection = db["dance_parties"]
84
+ collection.find.count.should == 0
85
+ MongoSessionStore.collection_name = "dance_parties"
86
+ create_user
87
+ collection.find.count.should == 1
88
+ end
89
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+ require 'securerandom'
3
+ require 'ostruct'
4
+ require 'mongo_session_store/mongo_store_base'
5
+
6
+ describe ActionDispatch::Session::MongoStoreBase do
7
+ ENV_SESSION_OPTIONS_KEY = ActionDispatch::Session::MongoStoreBase::ENV_SESSION_OPTIONS_KEY
8
+ SESSION_RECORD_KEY = ActionDispatch::Session::MongoStoreBase::SESSION_RECORD_KEY
9
+
10
+ Session = ActionDispatch::Session::MongoStoreBase::Session = Class.new(OpenStruct)
11
+
12
+ before do
13
+ @app = nil
14
+ @store = ActionDispatch::Session::MongoStoreBase.new(@app)
15
+ @env = {}
16
+ end
17
+
18
+ describe "#get_session" do
19
+ it "generates a new session id if given a nil session id" do
20
+ Session.stub(where: [])
21
+
22
+ sid, session_data = @store.send(:get_session, @env, nil)
23
+
24
+ sid.should_not == nil
25
+ session_data.should == nil
26
+ @env[SESSION_RECORD_KEY].class.should == Session
27
+ @env[SESSION_RECORD_KEY]._id.should == sid
28
+ end
29
+
30
+ it "generates a new session id if session is not found" do
31
+ old_sid = SecureRandom.hex
32
+ Session.stub(where: [])
33
+
34
+ sid, session_data = @store.send(:get_session, @env, old_sid)
35
+
36
+ sid.should_not == old_sid
37
+ session_data.should == nil
38
+ @env[SESSION_RECORD_KEY].class.should == Session
39
+ @env[SESSION_RECORD_KEY]._id.should == sid
40
+ end
41
+ end
42
+ end