multi_session 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +110 -0
  4. data/Rakefile +12 -0
  5. data/lib/generators/multi_session/install_generator.rb +10 -0
  6. data/lib/generators/templates/multi_session.rb +7 -0
  7. data/lib/multi_session/helper.rb +21 -0
  8. data/lib/multi_session/railtie.rb +7 -0
  9. data/lib/multi_session/session.rb +59 -0
  10. data/lib/multi_session/version.rb +3 -0
  11. data/lib/multi_session.rb +15 -0
  12. data/spec/dummy/Rakefile +6 -0
  13. data/spec/dummy/app/assets/config/manifest.js +2 -0
  14. data/spec/dummy/app/assets/javascripts/application.js +14 -0
  15. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  16. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  17. data/spec/dummy/app/controllers/multi_session_test_controller.rb +18 -0
  18. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  19. data/spec/dummy/app/jobs/application_job.rb +2 -0
  20. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  21. data/spec/dummy/app/views/multi_session_test/some_action.html.erb +1 -0
  22. data/spec/dummy/bin/bundle +3 -0
  23. data/spec/dummy/bin/rails +4 -0
  24. data/spec/dummy/bin/rake +4 -0
  25. data/spec/dummy/bin/setup +25 -0
  26. data/spec/dummy/bin/update +25 -0
  27. data/spec/dummy/config/application.rb +29 -0
  28. data/spec/dummy/config/boot.rb +5 -0
  29. data/spec/dummy/config/credentials.yml.enc +1 -0
  30. data/spec/dummy/config/environment.rb +5 -0
  31. data/spec/dummy/config/environments/development.rb +40 -0
  32. data/spec/dummy/config/environments/production.rb +68 -0
  33. data/spec/dummy/config/environments/test.rb +36 -0
  34. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  35. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  36. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  37. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  38. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/spec/dummy/config/initializers/inflections.rb +16 -0
  40. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  41. data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
  42. data/spec/dummy/config/locales/en.yml +33 -0
  43. data/spec/dummy/config/master.key +1 -0
  44. data/spec/dummy/config/puma.rb +34 -0
  45. data/spec/dummy/config/routes.rb +5 -0
  46. data/spec/dummy/config/spring.rb +6 -0
  47. data/spec/dummy/config.ru +5 -0
  48. data/spec/dummy/log/development.log +0 -0
  49. data/spec/dummy/log/test.log +396 -0
  50. data/spec/dummy/public/404.html +67 -0
  51. data/spec/dummy/public/422.html +67 -0
  52. data/spec/dummy/public/500.html +66 -0
  53. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  54. data/spec/dummy/public/apple-touch-icon.png +0 -0
  55. data/spec/dummy/public/favicon.ico +0 -0
  56. data/spec/requests/multi_session_spec.rb +40 -0
  57. data/spec/spec_helper.rb +19 -0
  58. metadata +188 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
File without changes
@@ -0,0 +1,40 @@
1
+ RSpec.describe 'multi_session', type: :request do
2
+ it 'renders the root page without error' do
3
+ get '/'
4
+ expect(response.body).to include('<h1>hello world!</h1>')
5
+ end
6
+
7
+ it 'encrypts and decrypts multi_session cookies' do
8
+ session_values = {
9
+ aaaa: 'alpha',
10
+ bbbb: 'bravo',
11
+ cccc: 'charlie',
12
+ dddd: 'delta',
13
+ eeee: 'echo'
14
+ }
15
+ get '/encrypt_multi_sessions', params: {session_values: session_values}
16
+
17
+ expect(response.status).to eq(200)
18
+ session_values.each do |session_key, value|
19
+ expect(response.cookies).to have_key(session_key.to_s)
20
+ expect(response.cookies[session_key.to_s].length > value.length).to be true
21
+ end
22
+
23
+ get '/decrypt_multi_sessions', params: {session_keys: session_values.keys}
24
+ expected_response = session_values.map{|k,v| "#{k}-#{v}"}.join(',')
25
+ expect(response.body).to eq(expected_response)
26
+ end
27
+
28
+ it 'can set session cookies as expirable' do
29
+ expires = 2.days
30
+ MultiSession.setup do |config|
31
+ config.expires = expires
32
+ end
33
+ get '/encrypt_multi_sessions', params: {session_values: {aaaa: 'alpha'}}
34
+
35
+ aaaa_cookie_string = response.headers['Set-Cookie'].split("\n").select{|str| str.include?('aaaa=')}.first
36
+ expire_string = "expires=#{(Time.zone.now + expires).strftime('%a, %d %b %Y %H')}"
37
+
38
+ expect(aaaa_cookie_string).to include(expire_string)
39
+ end
40
+ end
@@ -0,0 +1,19 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ ENV['RAILS_ENV'] ||= 'test'
5
+
6
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
7
+ require 'rspec/rails'
8
+
9
+ RSpec.configure do |config|
10
+ # Enable flags like --only-failures and --next-failure
11
+ config.example_status_persistence_file_path = '.rspec_status'
12
+
13
+ # Disable RSpec exposing methods globally on `Module` and `main`
14
+ config.disable_monkey_patching!
15
+
16
+ config.expect_with :rspec do |c|
17
+ c.syntax = :expect
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: multi_session
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sean Huber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - seanhuber@seanhuber.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - lib/generators/multi_session/install_generator.rb
66
+ - lib/generators/templates/multi_session.rb
67
+ - lib/multi_session.rb
68
+ - lib/multi_session/helper.rb
69
+ - lib/multi_session/railtie.rb
70
+ - lib/multi_session/session.rb
71
+ - lib/multi_session/version.rb
72
+ - spec/dummy/Rakefile
73
+ - spec/dummy/app/assets/config/manifest.js
74
+ - spec/dummy/app/assets/javascripts/application.js
75
+ - spec/dummy/app/assets/stylesheets/application.css
76
+ - spec/dummy/app/controllers/application_controller.rb
77
+ - spec/dummy/app/controllers/multi_session_test_controller.rb
78
+ - spec/dummy/app/helpers/application_helper.rb
79
+ - spec/dummy/app/jobs/application_job.rb
80
+ - spec/dummy/app/views/layouts/application.html.erb
81
+ - spec/dummy/app/views/multi_session_test/some_action.html.erb
82
+ - spec/dummy/bin/bundle
83
+ - spec/dummy/bin/rails
84
+ - spec/dummy/bin/rake
85
+ - spec/dummy/bin/setup
86
+ - spec/dummy/bin/update
87
+ - spec/dummy/config.ru
88
+ - spec/dummy/config/application.rb
89
+ - spec/dummy/config/boot.rb
90
+ - spec/dummy/config/credentials.yml.enc
91
+ - spec/dummy/config/environment.rb
92
+ - spec/dummy/config/environments/development.rb
93
+ - spec/dummy/config/environments/production.rb
94
+ - spec/dummy/config/environments/test.rb
95
+ - spec/dummy/config/initializers/application_controller_renderer.rb
96
+ - spec/dummy/config/initializers/backtrace_silencers.rb
97
+ - spec/dummy/config/initializers/content_security_policy.rb
98
+ - spec/dummy/config/initializers/cookies_serializer.rb
99
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
100
+ - spec/dummy/config/initializers/inflections.rb
101
+ - spec/dummy/config/initializers/mime_types.rb
102
+ - spec/dummy/config/initializers/wrap_parameters.rb
103
+ - spec/dummy/config/locales/en.yml
104
+ - spec/dummy/config/master.key
105
+ - spec/dummy/config/puma.rb
106
+ - spec/dummy/config/routes.rb
107
+ - spec/dummy/config/spring.rb
108
+ - spec/dummy/log/development.log
109
+ - spec/dummy/log/test.log
110
+ - spec/dummy/public/404.html
111
+ - spec/dummy/public/422.html
112
+ - spec/dummy/public/500.html
113
+ - spec/dummy/public/apple-touch-icon-precomposed.png
114
+ - spec/dummy/public/apple-touch-icon.png
115
+ - spec/dummy/public/favicon.ico
116
+ - spec/requests/multi_session_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/seanhuber/multi_session
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.7.3
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Creates multiple sessions for Rails
142
+ test_files:
143
+ - spec/spec_helper.rb
144
+ - spec/dummy/app/jobs/application_job.rb
145
+ - spec/dummy/app/controllers/application_controller.rb
146
+ - spec/dummy/app/controllers/multi_session_test_controller.rb
147
+ - spec/dummy/app/views/multi_session_test/some_action.html.erb
148
+ - spec/dummy/app/views/layouts/application.html.erb
149
+ - spec/dummy/app/assets/config/manifest.js
150
+ - spec/dummy/app/assets/javascripts/application.js
151
+ - spec/dummy/app/assets/stylesheets/application.css
152
+ - spec/dummy/app/helpers/application_helper.rb
153
+ - spec/dummy/bin/update
154
+ - spec/dummy/bin/rake
155
+ - spec/dummy/bin/setup
156
+ - spec/dummy/bin/bundle
157
+ - spec/dummy/bin/rails
158
+ - spec/dummy/config/routes.rb
159
+ - spec/dummy/config/locales/en.yml
160
+ - spec/dummy/config/environments/production.rb
161
+ - spec/dummy/config/environments/development.rb
162
+ - spec/dummy/config/environments/test.rb
163
+ - spec/dummy/config/spring.rb
164
+ - spec/dummy/config/master.key
165
+ - spec/dummy/config/environment.rb
166
+ - spec/dummy/config/application.rb
167
+ - spec/dummy/config/puma.rb
168
+ - spec/dummy/config/credentials.yml.enc
169
+ - spec/dummy/config/boot.rb
170
+ - spec/dummy/config/initializers/application_controller_renderer.rb
171
+ - spec/dummy/config/initializers/backtrace_silencers.rb
172
+ - spec/dummy/config/initializers/mime_types.rb
173
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
174
+ - spec/dummy/config/initializers/wrap_parameters.rb
175
+ - spec/dummy/config/initializers/cookies_serializer.rb
176
+ - spec/dummy/config/initializers/content_security_policy.rb
177
+ - spec/dummy/config/initializers/inflections.rb
178
+ - spec/dummy/config.ru
179
+ - spec/dummy/Rakefile
180
+ - spec/dummy/public/favicon.ico
181
+ - spec/dummy/public/422.html
182
+ - spec/dummy/public/apple-touch-icon.png
183
+ - spec/dummy/public/500.html
184
+ - spec/dummy/public/404.html
185
+ - spec/dummy/public/apple-touch-icon-precomposed.png
186
+ - spec/dummy/log/test.log
187
+ - spec/dummy/log/development.log
188
+ - spec/requests/multi_session_spec.rb