messagesodium 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bbe8437f3f0156fccf90bb3defdf1b565057196
4
- data.tar.gz: 01b0de5ed925df8cc9c501b83b07899acfa83b9b
3
+ metadata.gz: ab737303b92992980e7aa7189686b57603c40cea
4
+ data.tar.gz: 3d3216c1bfbc8174f4ed8d4a1808a44c7b3d515a
5
5
  SHA512:
6
- metadata.gz: 7d901c443944865798e2485a7d78da76abdd6110d2d432f1255887c5352bd5470691290cfb74b3c297e6b4f98d71d3348f2cb7d6c3c22ee3c71e21bb6b271a15
7
- data.tar.gz: 75cb3cafda0ebbd2792c8f7a049f3fa0854dcfe8e10e88ccb0b7a2968c654f5bfb0af74acb80d7ce04e83d1657e494da41bc4b352f8fe231c2b539fe4001ff21
6
+ metadata.gz: 6f267c8fc47f1741adfb8b239cf7e71f9b5e44d9ff2f1735f72c44f6916d2d0db74db9cd3d0d6bfcab4e37a10e98da80de7fa4a8e17060ae4fc4b6224fe5a7d5
7
+ data.tar.gz: 4024beeed614f60c3831940d0295f9baf14ef7cae9d627c1832d70ae46be2803e877579f8567459960fd192f005bb61689071adb169caee7b230f8db53f88ecb
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # Messagesodium
2
2
 
3
- Project status: Turbo Pre-alpha
3
+ Project status: 1.0 Release candidate
4
4
 
5
5
  Patches Cookiestore to use libsodium for encryption and verification.
6
+ [![Build Status](https://travis-ci.org/technion/messagesodium.svg?branch=master)](https://travis-ci.org/technion/messagesodium)
6
7
 
7
8
  # Cookistore
8
9
 
9
- Rails [Cookiestore](https://www.justinweiss.com/articles/how-rails-sessions-work/) is a heavily underrated feature. It bought commonsense to session management at a time when [saving every user session in its own tmpfile on a server](http://php.net/manual/en/function.session-start.php) was slow and unreasonable to scale, and XXX.
10
+ Rails [Cookiestore](https://www.justinweiss.com/articles/how-rails-sessions-work/) is a heavily underrated feature. It bought commonsense to session management at a time when [saving every user session in its own tmpfile on a server](http://php.net/manual/en/function.session-start.php) was slow and unreasonable to scale. And finally it avoided by default the horrible security issues we've seen with directly storing session variables in a cookie.
10
11
 
11
12
  This gem brings an alternative backend to CookieStore.
12
13
 
@@ -65,7 +66,7 @@ What you'll find in this gem is a much smaller, more easily audited codebase wit
65
66
 
66
67
  # Approach
67
68
 
68
- This gem is designed largely as a drop-in replacement for MessageEncryptor, which in turn is used by CookieStore. In a defualt environment, Rails astracts away everything I say below.
69
+ This gem is designed largely as a drop-in replacement for MessageEncryptor, which in turn is used by CookieStore. In a default environment, Rails astracts away everything I say below.
69
70
 
70
71
  MessageEncryptor takes a "secret", and a "signing secret", using them as two different secrets. Libsodium only needs a 256-bit secret.
71
72
 
@@ -1,3 +1,3 @@
1
1
  module Messagesodium
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
data/lib/messagesodium.rb CHANGED
@@ -25,13 +25,18 @@ module ActiveSupport
25
25
  # Encrypt and authenticate using libsodium XSalsa20/Poly1305
26
26
  # Serialise with JSON.dump
27
27
  # Returns base64(random nonce + cipher + auth tag)
28
+ # URLSafe encoding means it doesn't have to be mangled further to
29
+ # become a cookie
28
30
  def encrypt_and_sign(value)
29
- Base64.strict_encode64(@box.encrypt(::JSON.dump(value)))
31
+ Base64.urlsafe_encode64(@box.encrypt(::JSON.dump(value)))
30
32
  end
31
33
 
32
34
  # Decrypt the message, and check the auth tag in the process.
33
35
  def decrypt_and_verify(value)
34
- ::JSON.parse(@box.decrypt(Base64.decode64(value)), symbolize_names: true)
36
+ ::JSON.parse(
37
+ @box.decrypt(
38
+ Base64.urlsafe_decode64(value)),
39
+ symbolize_names: true)
35
40
  rescue RbNaCl::CryptoError
36
41
  raise InvalidMessage
37
42
  end
@@ -10,7 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["technion@lolware.net"]
11
11
 
12
12
  spec.summary = %q{Patches MessageEncryptor/Cookiestore to use Libsodium .}
13
- spec.description = %q{Introduces modern crypto, higher performance, smaller cookies to your sessions.}
13
+ spec.description = 'Introduces modern crypto, higher performance,' \
14
+ ' smaller cookies to your sessions.'
14
15
  spec.homepage = "https://github.com/technion/messagesodium"
15
16
  spec.license = "MIT"
16
17
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: messagesodium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Technion
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-04 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbnacl-libsodium