utopia 1.9.7 → 1.9.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9bc54b61be14c1139beeb8ae6d9b0471af71ed3
4
- data.tar.gz: d02c8b632f6a178de9d5dacca45fdd57bc60187b
3
+ metadata.gz: 7de52a1351fcb76d75ab943aec244d0e99073efb
4
+ data.tar.gz: 32969072fce26646b6d2ce0eba41237df56f0ade
5
5
  SHA512:
6
- metadata.gz: be7aebb371a373877f1dce7821c610da79108c0f0c06199333fa1760fbf4a43d55ec729e77f2c8534da966405a3fd21c78402b59b5298210149b0cccb9c4c088
7
- data.tar.gz: 0766cbf74bdb393329b3ee5d1c037e20b6c3cc6f0d7d63308f655648894b22ae0dc9ccff6fd8578d6c047e8702142dcd5a89dee4f56e67972b9b44e85201cf7f
6
+ metadata.gz: 34065160efd55c5a1c1f764a4ac5bad05439f59cfe0d5136d8c6f9c774686d8d4470fbd223ed9dcf88b73fb1bc027b3b0034655b7b6fb3e654e301b7e0ddd781
7
+ data.tar.gz: 3afdb9c05d5e2dec4e55c2d70f81c1880d7db49a0420cc57928c220a0808bc6ecd1d5d4e78cc6cc8cc42d950d0a4174e73125248c215867d35eb31bbb3d338b4
data/.travis.yml CHANGED
@@ -7,6 +7,7 @@ before_install:
7
7
  rvm:
8
8
  - 2.2.4
9
9
  - 2.3.2
10
+ - 2.4.0
10
11
  - ruby-head
11
12
  - rbx-3.65
12
13
  env: COVERAGE=true BENCHMARK=true
@@ -9,3 +9,21 @@ use Utopia::Session,
9
9
  ```
10
10
 
11
11
  All session data is stored on the client, but it's encrypted with a salt and the secret key. It would be hard for the client to decrypt the data without the secret.
12
+
13
+ ## Using `environment.yaml`
14
+
15
+ The session secret should not be shared or ideally, not stored in source code. This can be easily achieved using an environment variable, stored in `environment.yaml` on the production server:
16
+
17
+ ```ruby
18
+ use Utopia::Session,
19
+ :expires_after => 3600,
20
+ :secret => ENV['UTOPIA_SESSION_SECRET']
21
+ ```
22
+
23
+ In development, the secret would be reset every time the server is restarted. To set a fixed secret on production, run the following:
24
+
25
+ ```bash
26
+ $ utopia server environment UTOPIA_SESSION_SECRET=$(head /dev/urandom | shasum | base64 | head -c 40)
27
+ ```
28
+
29
+ This is done by default when using `utopia server create` and `utopia server update`.
@@ -26,6 +26,7 @@ require 'find'
26
26
  require 'yaml/store'
27
27
 
28
28
  require 'samovar'
29
+ require 'securerandom'
29
30
 
30
31
  module Utopia
31
32
  module Command
@@ -58,6 +59,15 @@ module Utopia
58
59
  yield store
59
60
  end
60
61
  end
62
+
63
+ # Set some useful defaults for the environment:
64
+ def self.update_default_environment(root)
65
+ # Set up some useful defaults for server environment:
66
+ environment(root) do |store|
67
+ store['RACK_ENV'] ||= 'production'
68
+ store['UTOPIA_SESSION_SECRET'] ||= SecureRandom.hex(40)
69
+ end
70
+ end
61
71
  end
62
72
  end
63
73
 
@@ -80,6 +90,8 @@ module Utopia
80
90
  # Copy git hooks:
81
91
  system("cp", "-r", File.join(Setup::Server::ROOT, 'git', 'hooks'), File.join(destination_root, '.git'))
82
92
 
93
+ Setup::Server.update_default_environment(destination_root)
94
+
83
95
  # Print out helpful git remote add message:
84
96
  hostname = `hostname`.chomp
85
97
  puts "Now add the git remote to your local repository:\n\tgit remote add production ssh://#{hostname}#{destination_root}"
@@ -100,6 +112,7 @@ module Utopia
100
112
 
101
113
  # Copy git hooks:
102
114
  system("cp", "-r", File.join(Setup::Server::ROOT, 'git', 'hooks'), File.join(destination_root, '.git'))
115
+ Setup::Server.update_default_environment(destination_root)
103
116
  end
104
117
  end
105
118
 
@@ -42,9 +42,9 @@ module Utopia
42
42
  @session_name = session_name || RACK_SESSION
43
43
  @cookie_name = @session_name + ".encrypted"
44
44
 
45
- if secret.nil?
45
+ if secret.nil? or secret.empty?
46
46
  secret = SecureRandom.hex(32)
47
- warn "#{self.class} secret is nil, generating transient secret key!"
47
+ warn "#{self.class} secret is #{secret.inspect}, generating transient secret key!"
48
48
  end
49
49
 
50
50
  # This generates a 32-byte key suitable for aes.
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "1.9.7"
22
+ VERSION = "1.9.9"
23
23
  end
data/setup/site/config.ru CHANGED
@@ -31,6 +31,11 @@ use Utopia::Localization,
31
31
  :locales => ['en', 'de', 'ja', 'zh'],
32
32
  :nonlocalized => ['/_static/', '/_cache/', '/_components/']
33
33
 
34
+ require 'utopia/session'
35
+ use Utopia::Session,
36
+ :expires_after => 3600 * 24,
37
+ :secret => ENV['UTOPIA_SESSION_SECRET']
38
+
34
39
  use Utopia::Controller,
35
40
  cache_controllers: (RACK_ENV == :production),
36
41
  base: Utopia::Controller::Base
@@ -73,6 +73,9 @@ RSpec.describe "utopia executable" do
73
73
  expect(result).to be == 0
74
74
 
75
75
  expect(Dir.entries(dir)).to include(".git")
76
+
77
+ environment = YAML.load_file(File.join(dir, 'config/environment.yaml'))
78
+ expect(environment).to include('RACK_ENV', 'UTOPIA_SESSION_SECRET')
76
79
  end
77
80
  end
78
81
 
data/utopia.gemspec CHANGED
@@ -1,7 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'utopia/version'
2
+ require_relative 'lib/utopia/version'
5
3
 
6
4
  Gem::Specification.new do |spec|
7
5
  spec.name = 'utopia'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utopia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.7
4
+ version: 1.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-19 00:00:00.000000000 Z
11
+ date: 2017-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trenni
@@ -392,7 +392,6 @@ files:
392
392
  - materials/utopia.png
393
393
  - materials/utopia.svg
394
394
  - setup/.bowerrc
395
- - setup/server/config/environment.yaml
396
395
  - setup/server/git/hooks/post-receive
397
396
  - setup/site/.bowerrc
398
397
  - setup/site/.rspec
@@ -1 +0,0 @@
1
- RACK_ENV=production