encrypted-cookie-store 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,51 @@
1
+ = Encrypted Cookie Store
2
+
3
+ == Description
4
+
5
+ Encrypted cookie based session for Rails 3.
6
+
7
+ == Summary
8
+
9
+ There are times when one must store things in a session that are not necessarily meant for anyone's eyes. Database or memcache sessions should be used for highly confidential information, however, for information that is not mission critical but still could benefit from a little discretion, an encrypted session cookie might be a good option. EncryptedCookieStore is a drop in replacement for the built in ActionDispatch::Session::CookieStore. +encrypted-cookie-store+ uses the +encrypted-cookies+ gem to store the session information in an encrypted and signed cookie, instead of only using a signed cookie, as ActionDispatch::Session::CookieStore does.
10
+
11
+ == Usage
12
+
13
+ Enabling an EncryptedCookieStore is easy. Just add the gem requirement to your +Gemfile+:
14
+
15
+ gem 'encrypted-cookie-store'
16
+
17
+ Then update then session store you are using in +config/initializers/session_store.rb+:
18
+
19
+ AppName::Application.config.session_store :encrypted_cookie_store, :key => '_app_name_session'
20
+
21
+ Writing and reading from the session is the same:
22
+
23
+ session[:tid_bit] = "of information"
24
+ session[:tid_bit] # => "of information"
25
+
26
+ == Disclaimer
27
+
28
+ This is provided as is. No guarantee is given for the security of the data written or read by this software. This has not been tested for cryptographic rigor. Use at your own discretion and risk. This should not be only level of security you use for your data. It uses ActiveSupport::MessageEncryptor to encrypt and ActiveSupport::MessageVerifier to sign the cookie values, so it is at best as secure as these two libraries. Be sure to keep your AppName::Application.config.secret_token safe and secret, as both of the above libraries use it in your Rails application.
29
+
30
+ == License
31
+
32
+ Copyright (c) 2011 Les Fletcher
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining
35
+ a copy of this software and associated documentation files (the
36
+ "Software"), to deal in the Software without restriction, including
37
+ without limitation the rights to use, copy, modify, merge, publish,
38
+ distribute, sublicense, and/or sell copies of the Software, and to
39
+ permit persons to whom the Software is furnished to do so, subject to
40
+ the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be
43
+ included in all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
46
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
49
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
50
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
51
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "encrypted-cookie-store/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "encrypted-cookie-store"
7
+ s.version = EncryptedCookieStore::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Les Fletcher"]
10
+ s.email = ["les.fletcher@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Encrypted cookie session store for Rails 3}
13
+ s.description = %q{Add an encrypted cookie session store for Rails 3}
14
+
15
+ s.rubyforge_project = "encrypted-cookie-store"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency('rails', '~> 3.0.0')
23
+ s.add_dependency('encrypted-cookies', '~> 0.1')
24
+ end
@@ -0,0 +1 @@
1
+ require 'encrypted-cookie-store/encrypted_cookie_store.rb'
@@ -0,0 +1,22 @@
1
+ module EncryptedCookieStore
2
+ # swap out the signed cookie jar for an encrypted cookie jar
3
+ class EncryptedCookieStore < ActionDispatch::Session::CookieStore
4
+ def unpacked_cookie_data(env)
5
+ env["action_dispatch.request.unsigned_session_cookie"] ||= begin
6
+ stale_session_check! do
7
+ request = ActionDispatch::Request.new(env)
8
+ if data = request.cookie_jar.encrypted[@key]
9
+ data.stringify_keys!
10
+ end
11
+ data || {}
12
+ end
13
+ end
14
+ end
15
+
16
+ def set_cookie(request, options)
17
+ request.cookie_jar.encrypted[@key] = options
18
+ end
19
+ end
20
+ end
21
+
22
+ ActionDispatch::Session.send(:include, EncryptedCookieStore)
@@ -0,0 +1,3 @@
1
+ module EncryptedCookieStore
2
+ VERSION = "0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: encrypted-cookie-store
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: "0.1"
6
+ platform: ruby
7
+ authors:
8
+ - Les Fletcher
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-04-03 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rails
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 3.0.0
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: encrypted-cookies
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: "0.1"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description: Add an encrypted cookie session store for Rails 3
39
+ email:
40
+ - les.fletcher@gmail.com
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files: []
46
+
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - README.rdoc
51
+ - Rakefile
52
+ - encrypted-cookie-store.gemspec
53
+ - lib/encrypted-cookie-store.rb
54
+ - lib/encrypted-cookie-store/encrypted_cookie_store.rb
55
+ - lib/encrypted-cookie-store/version.rb
56
+ has_rdoc: true
57
+ homepage: ""
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options: []
62
+
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project: encrypted-cookie-store
80
+ rubygems_version: 1.5.0
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Encrypted cookie session store for Rails 3
84
+ test_files: []
85
+