rails-rack-session 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b14edc5240650ce821143554081ba5312b2fa65c
4
+ data.tar.gz: 6c88c9467343eba9a5b0eba285af7555c5b4cd4c
5
+ SHA512:
6
+ metadata.gz: 78daa4de95da822abcaeb994773189836af9f81132a44d0c5d3286b035c7f63655aefc103f976841adf57a4051795e75760f6b4c71bbb786cf1842e9366a7974
7
+ data.tar.gz: f20aabbc4cdc48fe25351fae1161cf37fda513f58cdc6ce4a20367fb0d6dd045f4212cb311be511ad42ba47e3700ae2de8d9b78c18646e1272bb5721ca9c2a21
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # RailsRackSessionCookie
2
+
3
+ By default, Rails 4+ comes with its own custom cookie storage mechanism that
4
+ encrypts cookie values. It is incompatible with Rack::Session::Cookie and only
5
+ necessary if you're storing sensitive information in your cookies (an
6
+ antipattern).
7
+
8
+ This gem allows you to seemlessly share a cookie among rack-based web
9
+ applications, provided they all use the built-in Rack::Session middleware.
10
+
11
+ ## How does it work?
12
+
13
+ This simply replaces the ActionDispatch cookie middleware with
14
+ Rack::Session::Storage. Unfortunately you cannot run ActionDispatch's cookie
15
+ middleware alongside Rack::Session::Storage because ActionDispatch overwrites
16
+ `env['rack.session']` with its custom cookie jar.
17
+
18
+ By using this gem, all your rack and rails apps must use Rack::Session::Storage
19
+ in order to share cookies.
20
+
21
+ ## Installation
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem 'rails-rack-session'
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ $ bundle
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install rails-rack-session
36
+
37
+ ## Configuration
38
+
39
+ In config/application.rb:
40
+
41
+ ```
42
+ config.rack_session = {
43
+ store: :cookie,
44
+ key: '_my_app',
45
+ secret
46
+ domain: '.example.com'
47
+ }
48
+ ```
49
+
50
+ The `:store` key corresponds to the name of a `Rack::Session` class, e.g. `Cookie`.
51
+ the `:secret` key is inferred from your app's `secret_key_base`, usually set in
52
+ `config/secrets.yml`.
53
+
54
+ Use the same keys used to configure Rack::Session. For cookie store, see
55
+ http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
56
+
57
+ ## Usage
58
+
59
+ This is a seamless drop-in as Rails' interface with the cookie store is
60
+ compatible with Rack::Session::Cookie.
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
65
+
66
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
67
+
68
+ ## Contributing
69
+
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/faradayio/rails-rack-session-cookie.
71
+
@@ -0,0 +1,5 @@
1
+ require "rails-rack-session/rails"
2
+ require "rails-rack-session/version"
3
+
4
+ module RailsRackSession
5
+ end
@@ -0,0 +1,45 @@
1
+ require 'rack'
2
+
3
+ module RailsRackSession
4
+
5
+ # Configure this plugin with:
6
+ #
7
+ # config.rack_session store: :cookie,
8
+ # key: '_my_app',
9
+ # domain: '.example.com'
10
+ #
11
+ # Use the same keys used to configure Rack::Session
12
+ # For cookie store, see http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
13
+ class Railtie < Rails::Railtie
14
+
15
+ initializer 'rack_session' do
16
+ cfg = config.respond_to?(:rack_session) ? config.rack_session : {}
17
+
18
+ if cfg[:store].nil?
19
+ raise <<-TXT
20
+ You must choose a session storage class using:
21
+ config.rack_session store: <class>
22
+
23
+ Available options: :cookie, :pool, :memcache
24
+ TXT
25
+ end
26
+
27
+ cfg[:secret] ||= app.secrets[:secret_key_base]
28
+
29
+ puts cfg.inspect
30
+
31
+ session_class = Rack::Session.const_get cfg.delete(:store).to_s.camelize
32
+
33
+ app.middleware.insert_before ActionDispatch::Cookies, session_class, cfg
34
+
35
+ app.middleware.delete ActionDispatch::Cookies
36
+ app.middleware.delete ActionDispatch::Session::CookieStore
37
+ end
38
+
39
+ def app
40
+ Rails.application
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,3 @@
1
+ module RailsRackSession
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-rack-session
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Derek Kastner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Enable sessions/cookies in Rails that are compatible with standard rack
70
+ apps
71
+ email:
72
+ - dkastner@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - README.md
78
+ - lib/rails-rack-session.rb
79
+ - lib/rails-rack-session/rails.rb
80
+ - lib/rails-rack-session/version.rb
81
+ homepage: http://github.com/dkastner/rails-rack-session
82
+ licenses: []
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.5.1
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Use classic Rack::Session::Cookie in Rails
104
+ test_files: []