utopia 1.9.7 → 1.9.9
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 +4 -4
- data/.travis.yml +1 -0
- data/documentation/pages/wiki/middleware/session/content.md +18 -0
- data/lib/utopia/command.rb +13 -0
- data/lib/utopia/session.rb +2 -2
- data/lib/utopia/version.rb +1 -1
- data/setup/site/config.ru +5 -0
- data/spec/utopia/setup_spec.rb +3 -0
- data/utopia.gemspec +1 -3
- metadata +2 -3
- data/setup/server/config/environment.yaml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7de52a1351fcb76d75ab943aec244d0e99073efb
|
4
|
+
data.tar.gz: 32969072fce26646b6d2ce0eba41237df56f0ade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34065160efd55c5a1c1f764a4ac5bad05439f59cfe0d5136d8c6f9c774686d8d4470fbd223ed9dcf88b73fb1bc027b3b0034655b7b6fb3e654e301b7e0ddd781
|
7
|
+
data.tar.gz: 3afdb9c05d5e2dec4e55c2d70f81c1880d7db49a0420cc57928c220a0808bc6ecd1d5d4e78cc6cc8cc42d950d0a4174e73125248c215867d35eb31bbb3d338b4
|
data/.travis.yml
CHANGED
@@ -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`.
|
data/lib/utopia/command.rb
CHANGED
@@ -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
|
|
data/lib/utopia/session.rb
CHANGED
@@ -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
|
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.
|
data/lib/utopia/version.rb
CHANGED
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
|
data/spec/utopia/setup_spec.rb
CHANGED
@@ -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
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.
|
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:
|
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
|