All Projects → cvonkleist → encrypted_cookie

cvonkleist / encrypted_cookie

Licence: MIT license
AES-128 encrypted session cookies for Rack (and Sinatra and other frameworks).

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to encrypted cookie

books
List of all Ruby books
Stars: ✭ 49 (-9.26%)
Mutual labels:  sinatra, gems
serverless-rack
Serverless plugin to deploy Ruby Rack applications (Sinatra/Rails/Padrino/Cuba etc.) and bundle gems
Stars: ✭ 58 (+7.41%)
Mutual labels:  rack, sinatra
sinator
Sinatra application generator
Stars: ✭ 19 (-64.81%)
Mutual labels:  sinatra, gems
Async sinatra
A plugin for Sinatra to provide a DSL extension for using Thin for asynchronous responses
Stars: ✭ 434 (+703.7%)
Mutual labels:  rack, sinatra
Sham rack
run Rack applications in-process, without a server
Stars: ✭ 169 (+212.96%)
Mutual labels:  rack, sinatra
rack-cargo
🚚 Batch requests for Rack apps (works with Rails, Sinatra, etc)
Stars: ✭ 17 (-68.52%)
Mutual labels:  rack, sinatra
rack-simple user agent
Rack::SimpleUserAgent is stupidly simple UA detector
Stars: ✭ 13 (-75.93%)
Mutual labels:  rack, sinatra
Ferrocarril
🚆 Experiments to embed Ruby on Rails in Rust with mruby
Stars: ✭ 66 (+22.22%)
Mutual labels:  rack, sinatra
Sinatra
Classy web-development dressed in a DSL (official / canonical repo)
Stars: ✭ 11,497 (+21190.74%)
Mutual labels:  rack, sinatra
Bugsnag Ruby
Bugsnag error monitoring & reporting software for rails, sinatra, rack and ruby
Stars: ✭ 211 (+290.74%)
Mutual labels:  rack, sinatra
Rack Reducer
Declaratively filter data via URL params, in any Rack app, with any ORM.
Stars: ✭ 241 (+346.3%)
Mutual labels:  rack, sinatra
sinatra-dev-cheatsheet
A quick-and-dirty cheat sheet for creating HTML/CSS websites, and developing using Sinatra and ActiveRecord.
Stars: ✭ 44 (-18.52%)
Mutual labels:  sinatra
api
Tendrl API
Stars: ✭ 16 (-70.37%)
Mutual labels:  sinatra
dyndnsd
A small, lightweight and extensible DynDNS server written with Ruby and Rack.
Stars: ✭ 69 (+27.78%)
Mutual labels:  rack
rubynepal.github.io
Official website of Ruby Nepal
Stars: ✭ 21 (-61.11%)
Mutual labels:  sinatra
git
git (and github) & monorepo / mono source tree command line tools, libraries & scripts
Stars: ✭ 16 (-70.37%)
Mutual labels:  gems
anycable-rack-server
AnyCable-compatible Ruby Rack middleware
Stars: ✭ 21 (-61.11%)
Mutual labels:  rack
sickbay
Get the HTTP status of a bunch of URLs in a single JSON response. Ideal for monitoring a lot of services at once.
Stars: ✭ 19 (-64.81%)
Mutual labels:  sinatra
sinatra-bootstrap
My opinionated Sinatra base application
Stars: ✭ 14 (-74.07%)
Mutual labels:  sinatra
rack-reproxy
Transparently proxy Rack responses from a backend URL. Great for private access to an internal service or to route authenticated requests through intermediate caching layers.
Stars: ✭ 20 (-62.96%)
Mutual labels:  rack

Encrypted session cookies for Rack (and therefore Sinatra)

Ruby

The encrypted_cookie gem provides 256-bit-AES-encrypted, tamper-proof cookies for Rack through the class Rack::Session::EncryptedCookie.

How to use encrypted_cookie

$ gem install encrypted_cookie

Sinatra example:

require 'sinatra'
require 'encrypted_cookie'

use Rack::Session::EncryptedCookie,
  :secret => TYPE_YOUR_LONG_RANDOM_STRING_HERE*

get '/' do
  session[:foo] = 'bar'
  "session: " + session.inspect
end

* Your :secret must be at least 32 bytes long and should be really random. Don't use a password or passphrase, generate something random (see below).

Encryption and integrity protection

The cookie is encrypted with 256-bit AES in CBC mode (with random IV). The encrypted cookie is then signed with a HMAC, to prevent tampering and chosen ciphertext attacks. Any attempt at tampering with the cookie will reset the user to {} (empty hash).

Generating a good secret

Run this in a terminal and paste the output into your script:

$ ruby -rsecurerandom -e "puts SecureRandom.hex(32)"

Developing

To get the specs running:

$ cd path-to-clone
$ gem install bundler # if not already installed
$ bundle install
$ bundle exec rspec

Thanks

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].