pakyow-core 1.0.0.rc1 → 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pakyow/app/connection/behavior/verifier.rb +14 -6
- data/lib/pakyow/app/connection/session/cookie.rb +14 -3
- data/lib/pakyow/behavior/config.rb +1 -1
- data/lib/pakyow/behavior/sessions.rb +4 -2
- data/lib/pakyow/cli.rb +17 -2
- data/lib/pakyow/environment/behavior/config.rb +6 -0
- data/lib/pakyow/environment/behavior/verifier.rb +32 -0
- data/lib/pakyow/environment.rb +2 -0
- data/lib/pakyow/generators/project/default/Gemfile.erb +1 -5
- data/lib/pakyow/generators/project/default/frontend/layouts/default.html.erb +1 -1
- data/lib/pakyow/plugin/state.rb +3 -1
- data/lib/pakyow/task.rb +2 -0
- data/lib/pakyow/tasks/boot.rake +1 -1
- data/lib/pakyow/tasks/prototype.rake +20 -0
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80c64e0fbe8b4edcb3b10b4ac4cd640fbd4e4fb501108798f418cf0829289d50
|
4
|
+
data.tar.gz: ce5ebf0caebc91cbfd1c0c1463a9bcd9312fff947f1fef05aeec07df1833c486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9edb7dd91ee759baada1e3176644f9c7f409fce6f052f0dbe87dcdd7220ef946d22f90eb87add99a33ae5edfa0ed409e6104781fbf78fb8888b003a7c4fa27dc
|
7
|
+
data.tar.gz: bfe086b797fbf4501b7a549caffe0797949421e9a71eb04d243a7c44041ff05ef7f55c75db134ff9b25731f5fec174695db8dba4af8a56117b773d09c65c18d0
|
@@ -12,20 +12,28 @@ module Pakyow
|
|
12
12
|
|
13
13
|
apply_extension do
|
14
14
|
after "initialize" do
|
15
|
-
|
15
|
+
if app.config.session.enabled
|
16
|
+
session[:verifier_key] ||= Support::MessageVerifier.key
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
21
|
def verifier
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
if app.config.session.enabled
|
23
|
+
unless instance_variable_defined?(:@verifier)
|
24
|
+
@verifier = Support::MessageVerifier.new(verifier_key)
|
25
|
+
end
|
23
26
|
|
24
|
-
|
27
|
+
@verifier
|
28
|
+
else
|
29
|
+
nil
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
def verifier_key
|
28
|
-
session
|
34
|
+
if app.config.session.enabled
|
35
|
+
session[:verifier_key]
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "base64"
|
4
4
|
|
5
5
|
require "pakyow/support/indifferentize"
|
6
|
+
require "pakyow/support/message_verifier"
|
6
7
|
|
7
8
|
require "pakyow/app/connection/session/abstract"
|
8
9
|
|
@@ -12,7 +13,7 @@ module Pakyow
|
|
12
13
|
module Session
|
13
14
|
class Cookie < Abstract
|
14
15
|
def initialize(connection, options)
|
15
|
-
if (cookie = connection.cookies[options.name]) &&
|
16
|
+
if (cookie = connection.cookies[options.name]) && cookie.is_a?(Support::IndifferentHash)
|
16
17
|
super(connection, options, Support::IndifferentHash.new(cookie[:value].to_h))
|
17
18
|
connection.cookies[options.name][:value] = self
|
18
19
|
else
|
@@ -35,14 +36,24 @@ module Pakyow
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def to_s
|
38
|
-
Base64.urlsafe_encode64(
|
39
|
+
Base64.urlsafe_encode64(
|
40
|
+
Pakyow.verifier.sign(
|
41
|
+
Marshal.dump(to_h)
|
42
|
+
)
|
43
|
+
)
|
39
44
|
end
|
40
45
|
|
41
46
|
private
|
42
47
|
|
43
48
|
def deserialize(connection, options)
|
44
49
|
if value = connection.cookies[options.name]
|
45
|
-
Support::IndifferentHash.deep(
|
50
|
+
Support::IndifferentHash.deep(
|
51
|
+
Marshal.load(
|
52
|
+
Pakyow.verifier.verify(
|
53
|
+
Base64.urlsafe_decode64(value)
|
54
|
+
)
|
55
|
+
)
|
56
|
+
)
|
46
57
|
else
|
47
58
|
Support::IndifferentHash.new
|
48
59
|
end
|
@@ -25,8 +25,10 @@ module Pakyow
|
|
25
25
|
{}
|
26
26
|
end
|
27
27
|
end
|
28
|
-
rescue LoadError
|
29
|
-
# TODO:
|
28
|
+
rescue LoadError => error
|
29
|
+
# TODO: Improve this with a specific "session object missing" error.
|
30
|
+
#
|
31
|
+
raise error
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
data/lib/pakyow/cli.rb
CHANGED
@@ -92,7 +92,13 @@ module Pakyow
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
@
|
95
|
+
case @command
|
96
|
+
when "prototype"
|
97
|
+
@options.delete(:env)
|
98
|
+
else
|
99
|
+
@options[:env] ||= ENV["APP_ENV"] || ENV["RACK_ENV"] || "development"
|
100
|
+
end
|
101
|
+
|
96
102
|
ENV["APP_ENV"] = ENV["RACK_ENV"] = @options[:env]
|
97
103
|
end
|
98
104
|
|
@@ -115,7 +121,16 @@ module Pakyow
|
|
115
121
|
end
|
116
122
|
|
117
123
|
def setup_environment
|
118
|
-
Pakyow.setup(env:
|
124
|
+
Pakyow.setup(env: environment_to_setup)
|
125
|
+
end
|
126
|
+
|
127
|
+
def environment_to_setup
|
128
|
+
case @command
|
129
|
+
when "prototype"
|
130
|
+
:prototype
|
131
|
+
else
|
132
|
+
@options[:env]
|
133
|
+
end
|
119
134
|
end
|
120
135
|
|
121
136
|
def load_tasks
|
@@ -16,6 +16,8 @@ module Pakyow
|
|
16
16
|
setting :freeze_on_boot, true
|
17
17
|
setting :exit_on_boot_failure, true
|
18
18
|
setting :timezone, :utc
|
19
|
+
setting :secrets, ["pakyow"]
|
20
|
+
|
19
21
|
setting :connection_class do
|
20
22
|
require "pakyow/connection"
|
21
23
|
Connection
|
@@ -41,6 +43,10 @@ module Pakyow
|
|
41
43
|
setting :exit_on_boot_failure, false
|
42
44
|
end
|
43
45
|
|
46
|
+
defaults :production do
|
47
|
+
setting :secrets, [ENV["SECRET"].to_s.strip]
|
48
|
+
end
|
49
|
+
|
44
50
|
configurable :server do
|
45
51
|
setting :host, "localhost"
|
46
52
|
setting :port, 3000
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pakyow/support/extension"
|
4
|
+
require "pakyow/support/message_verifier"
|
5
|
+
|
6
|
+
module Pakyow
|
7
|
+
module Environment
|
8
|
+
module Behavior
|
9
|
+
module Verifier
|
10
|
+
extend Support::Extension
|
11
|
+
|
12
|
+
class_methods do
|
13
|
+
attr_reader :verifier
|
14
|
+
end
|
15
|
+
|
16
|
+
apply_extension do
|
17
|
+
before :boot do
|
18
|
+
config.secrets.reject! { |secret|
|
19
|
+
secret.nil? || secret.empty?
|
20
|
+
}
|
21
|
+
|
22
|
+
if config.secrets.any?
|
23
|
+
@verifier = Support::MessageVerifier.new(config.secrets[0])
|
24
|
+
else
|
25
|
+
raise "Pakyow will not boot without a secret configured in `Pakyow.config.secrets`"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pakyow/environment.rb
CHANGED
@@ -25,6 +25,7 @@ require "pakyow/environment/behavior/timezone"
|
|
25
25
|
require "pakyow/environment/behavior/running"
|
26
26
|
require "pakyow/environment/behavior/watching"
|
27
27
|
require "pakyow/environment/behavior/restarting"
|
28
|
+
require "pakyow/environment/behavior/verifier"
|
28
29
|
|
29
30
|
require "pakyow/environment/actions/dispatch"
|
30
31
|
require "pakyow/environment/actions/input_parser"
|
@@ -112,6 +113,7 @@ module Pakyow
|
|
112
113
|
include Environment::Behavior::Running
|
113
114
|
include Environment::Behavior::Watching
|
114
115
|
include Environment::Behavior::Restarting
|
116
|
+
include Environment::Behavior::Verifier
|
115
117
|
|
116
118
|
include Support::Pipeline
|
117
119
|
action Actions::Logger
|
@@ -9,15 +9,11 @@ gem "pakyow", github: "pakyow/pakyow", require: "pakyow/all"
|
|
9
9
|
gem "pakyow", "~> <%= Pakyow::VERSION %>", require: "pakyow/all"
|
10
10
|
<%- end -%>
|
11
11
|
|
12
|
-
# Use the puma application server.
|
13
|
-
#
|
14
|
-
gem "puma"
|
15
|
-
|
16
12
|
# Easily manage environment variables.
|
17
13
|
#
|
18
14
|
gem "dotenv"
|
19
15
|
|
20
|
-
group :development do
|
16
|
+
group :development, :prototype do
|
21
17
|
# Speed up project boot time.
|
22
18
|
#
|
23
19
|
gem "bootsnap", require: false
|
data/lib/pakyow/plugin/state.rb
CHANGED
@@ -26,7 +26,9 @@ module Pakyow
|
|
26
26
|
prefix: @plugin.class.mount_path
|
27
27
|
},
|
28
28
|
processor: Presenter::ProcessorCaller.new(
|
29
|
-
@plugin.parent.state(:processor)
|
29
|
+
@plugin.parent.state(:processor).map { |processor|
|
30
|
+
processor.new(@plugin.parent)
|
31
|
+
}
|
30
32
|
)
|
31
33
|
).tap do |plugin_templates|
|
32
34
|
if app_templates = @plugin.parent.state(:templates).find { |templates| templates.name == :default }
|
data/lib/pakyow/task.rb
CHANGED
@@ -293,6 +293,8 @@ module Pakyow
|
|
293
293
|
arguments: @__arguments,
|
294
294
|
options: CLI::GLOBAL_OPTIONS.select { |key, _|
|
295
295
|
key == :env || args[1].to_a.include?(key)
|
296
|
+
}.reject { |key, _|
|
297
|
+
key == :env && args[0] == :prototype
|
296
298
|
}.merge(@__options),
|
297
299
|
flags: @__flags,
|
298
300
|
task_args: args,
|
data/lib/pakyow/tasks/boot.rake
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
desc "Boot the
|
3
|
+
desc "Boot the project"
|
4
4
|
option :host, "The host the server runs on (default: #{Pakyow.config.server.host})"
|
5
5
|
option :port, "The port the server runs on (default: #{Pakyow.config.server.port})"
|
6
6
|
flag :standalone, "Disable automatic reloading of changes"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
desc "Boot the prototype"
|
4
|
+
option :host, "The host the server runs on (default: #{Pakyow.config.server.host})"
|
5
|
+
option :port, "The port the server runs on (default: #{Pakyow.config.server.port})"
|
6
|
+
task :prototype, [:host, :port] do |_, args|
|
7
|
+
if host = args[:host]
|
8
|
+
Pakyow.config.server.host = host
|
9
|
+
end
|
10
|
+
|
11
|
+
if port = args[:port]
|
12
|
+
Pakyow.config.server.port = port
|
13
|
+
end
|
14
|
+
|
15
|
+
if args[:standalone]
|
16
|
+
Pakyow.config.server.proxy = false
|
17
|
+
end
|
18
|
+
|
19
|
+
Pakyow.run
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pakyow-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: commands
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-07-
|
12
|
+
date: 2019-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pakyow-support
|
@@ -17,42 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.0.0.
|
20
|
+
version: 1.0.0.rc2
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.0.0.
|
27
|
+
version: 1.0.0.rc2
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: async
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1.
|
34
|
+
version: '1.19'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
41
|
+
version: '1.19'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: async-http
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0.
|
48
|
+
version: 0.46.3
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: 0.46.3
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: async-io
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,28 +87,28 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '1.
|
90
|
+
version: '1.4'
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '1.
|
97
|
+
version: '1.4'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: dry-types
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '1.
|
104
|
+
version: '1.1'
|
105
105
|
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '1.
|
111
|
+
version: '1.1'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: filewatcher
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- lib/pakyow/environment/behavior/running.rb
|
248
248
|
- lib/pakyow/environment/behavior/silencing.rb
|
249
249
|
- lib/pakyow/environment/behavior/timezone.rb
|
250
|
+
- lib/pakyow/environment/behavior/verifier.rb
|
250
251
|
- lib/pakyow/environment/behavior/watching.rb
|
251
252
|
- lib/pakyow/error.rb
|
252
253
|
- lib/pakyow/errors.rb
|
@@ -306,6 +307,7 @@ files:
|
|
306
307
|
- lib/pakyow/tasks/info/endpoints.rake
|
307
308
|
- lib/pakyow/tasks/irb.rake
|
308
309
|
- lib/pakyow/tasks/prelaunch.rake
|
310
|
+
- lib/pakyow/tasks/prototype.rake
|
309
311
|
- lib/pakyow/types.rb
|
310
312
|
- lib/pakyow/validations.rb
|
311
313
|
- lib/pakyow/validations/acceptance.rb
|
@@ -334,8 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
334
336
|
- !ruby/object:Gem::Version
|
335
337
|
version: 1.3.1
|
336
338
|
requirements: []
|
337
|
-
|
338
|
-
rubygems_version: 2.7.6
|
339
|
+
rubygems_version: 3.0.3
|
339
340
|
signing_key:
|
340
341
|
specification_version: 4
|
341
342
|
summary: Pakyow Core
|