tynn 1.0.0 → 1.1.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 +4 -4
- data/lib/tynn.rb +14 -12
- data/lib/tynn/all_methods.rb +1 -1
- data/lib/tynn/environment.rb +2 -2
- data/lib/tynn/force_ssl.rb +1 -1
- data/lib/tynn/hsts.rb +3 -3
- data/lib/tynn/json.rb +1 -1
- data/lib/tynn/matchers.rb +1 -1
- data/lib/tynn/protection.rb +7 -7
- data/lib/tynn/secure_headers.rb +2 -2
- data/lib/tynn/session.rb +3 -3
- data/lib/tynn/settings.rb +2 -2
- data/lib/tynn/static.rb +3 -3
- data/lib/tynn/version.rb +1 -1
- data/test/all_methods_test.rb +1 -1
- data/test/environment_test.rb +2 -2
- data/test/force_ssl_test.rb +2 -2
- data/test/hmote_test.rb +1 -1
- data/test/hsts_test.rb +2 -2
- data/test/json_test.rb +1 -1
- data/test/matchers_test.rb +1 -1
- data/test/not_found_test.rb +1 -1
- data/test/protection_test.rb +3 -3
- data/test/render_test.rb +1 -1
- data/test/secure_headers_test.rb +1 -1
- data/test/session_test.rb +1 -1
- data/test/static_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caaa63933cf9306d02ec269daf58276c16cd28d3
|
4
|
+
data.tar.gz: f42352bb844554c1dd98f020bbceec81e5f6a6bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22ca341ae338b0305f31632ee651dea757344c1e6185ef33f18d2821ea0af12202275e0dda1a811f2d4a89ffcc803f5cbad409e7e2188c85f7d773c0bf625c62
|
7
|
+
data.tar.gz: 29923d6637a08a4d0d945ccfafe95b2ed9dbe2643c76085bc5ee1c476f0c55dff973e906bca95ab1c458d2b04a13503b1aaaef9b98bdb8f15f81038d31d9929e
|
data/lib/tynn.rb
CHANGED
@@ -7,31 +7,33 @@ require_relative "tynn/version"
|
|
7
7
|
class Tynn
|
8
8
|
include Syro::Deck::API
|
9
9
|
|
10
|
-
# Public:
|
10
|
+
# Public: Loads given +plugin+ into the application.
|
11
11
|
#
|
12
12
|
# Examples
|
13
13
|
#
|
14
14
|
# require "tynn"
|
15
15
|
# require "tynn/protection"
|
16
|
+
# require "tynn/session"
|
16
17
|
#
|
17
|
-
# Tynn.
|
18
|
+
# Tynn.plugin(Tynn::Protection)
|
19
|
+
# Tynn.plugin(Tynn::Session, secret: "__a_random_secret_key")
|
18
20
|
#
|
19
|
-
def self.
|
20
|
-
if defined?(
|
21
|
-
self.include(
|
21
|
+
def self.plugin(plugin, *args, &block)
|
22
|
+
if defined?(plugin::InstanceMethods)
|
23
|
+
self.include(plugin::InstanceMethods)
|
22
24
|
end
|
23
25
|
|
24
|
-
if defined?(
|
25
|
-
self.extend(
|
26
|
+
if defined?(plugin::ClassMethods)
|
27
|
+
self.extend(plugin::ClassMethods)
|
26
28
|
end
|
27
29
|
|
28
|
-
if
|
29
|
-
|
30
|
+
if plugin.respond_to?(:setup)
|
31
|
+
plugin.setup(self, *args, &block)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
# Internal: Default
|
34
|
-
|
35
|
+
# Internal: Default plugins.
|
36
|
+
plugin(Tynn::Settings)
|
35
37
|
|
36
38
|
# Public: Sets the application handler.
|
37
39
|
#
|
@@ -98,7 +100,7 @@ class Tynn
|
|
98
100
|
# require "tynn"
|
99
101
|
# require "tynn/environment"
|
100
102
|
#
|
101
|
-
# Tynn.
|
103
|
+
# Tynn.plugin(Tynn::Environment)
|
102
104
|
#
|
103
105
|
# Tynn.set(:environment, :staging)
|
104
106
|
# Tynn.environment
|
data/lib/tynn/all_methods.rb
CHANGED
data/lib/tynn/environment.rb
CHANGED
@@ -6,7 +6,7 @@ class Tynn
|
|
6
6
|
# require "tynn"
|
7
7
|
# require "tynn/environment"
|
8
8
|
#
|
9
|
-
# Tynn.
|
9
|
+
# Tynn.plugin(Tynn::Environment)
|
10
10
|
#
|
11
11
|
# Tynn.environment # => :development
|
12
12
|
#
|
@@ -18,7 +18,7 @@ class Tynn
|
|
18
18
|
#
|
19
19
|
# Examples
|
20
20
|
#
|
21
|
-
# Tynn.
|
21
|
+
# Tynn.plugin(Tynn::Environment, env: ENV["RACK_ENV"])
|
22
22
|
#
|
23
23
|
module Environment
|
24
24
|
# Internal: Configures current environment.
|
data/lib/tynn/force_ssl.rb
CHANGED
data/lib/tynn/hsts.rb
CHANGED
@@ -9,7 +9,7 @@ class Tynn
|
|
9
9
|
# require "tynn"
|
10
10
|
# require "tynn/hsts"
|
11
11
|
#
|
12
|
-
# Tynn.
|
12
|
+
# Tynn.plugin(Tynn::HSTS)
|
13
13
|
#
|
14
14
|
# Tynn.define { }
|
15
15
|
#
|
@@ -33,7 +33,7 @@ class Tynn
|
|
33
33
|
#
|
34
34
|
# Examples
|
35
35
|
#
|
36
|
-
# Tynn.
|
36
|
+
# Tynn.plugin(
|
37
37
|
# Tynn::HSTS,
|
38
38
|
# expires: 31_536_000,
|
39
39
|
# includeSubdomains: true,
|
@@ -49,7 +49,7 @@ class Tynn
|
|
49
49
|
#
|
50
50
|
# Examples
|
51
51
|
#
|
52
|
-
# Tynn.
|
52
|
+
# Tynn.plugin(Tynn::HSTS, expires: 0)
|
53
53
|
#
|
54
54
|
module HSTS
|
55
55
|
# Internal: Sets the HSTS header as a default header.
|
data/lib/tynn/json.rb
CHANGED
data/lib/tynn/matchers.rb
CHANGED
data/lib/tynn/protection.rb
CHANGED
@@ -8,7 +8,7 @@ class Tynn
|
|
8
8
|
# require "tynn"
|
9
9
|
# require "tynn/protection"
|
10
10
|
#
|
11
|
-
# Tynn.
|
11
|
+
# Tynn.plugin(Tynn::Protection)
|
12
12
|
#
|
13
13
|
# If you are using SSL/TLS (HTTPS), it's recommended to set
|
14
14
|
# the +:ssl+ option:
|
@@ -18,9 +18,9 @@ class Tynn
|
|
18
18
|
# require "tynn"
|
19
19
|
# require "tynn/protection"
|
20
20
|
#
|
21
|
-
# Tynn.
|
21
|
+
# Tynn.plugin(Tynn::Protection, ssl: true)
|
22
22
|
#
|
23
|
-
# By default, it includes the following security
|
23
|
+
# By default, it includes the following security plugins:
|
24
24
|
#
|
25
25
|
# - Tynn::SecureHeaders
|
26
26
|
#
|
@@ -31,22 +31,22 @@ class Tynn
|
|
31
31
|
# - Tynn::ForceSSL
|
32
32
|
#
|
33
33
|
module Protection
|
34
|
-
# Internal: Configures security related
|
34
|
+
# Internal: Configures security related plugins.
|
35
35
|
def self.setup(app, ssl: false, force_ssl: ssl, hsts: {})
|
36
|
-
app.
|
36
|
+
app.plugin(Tynn::SecureHeaders)
|
37
37
|
|
38
38
|
if ssl
|
39
39
|
app.settings[:ssl] = true
|
40
40
|
|
41
41
|
require_relative "hsts"
|
42
42
|
|
43
|
-
app.
|
43
|
+
app.plugin(Tynn::HSTS, hsts)
|
44
44
|
end
|
45
45
|
|
46
46
|
if force_ssl
|
47
47
|
require_relative "force_ssl"
|
48
48
|
|
49
|
-
app.
|
49
|
+
app.plugin(Tynn::ForceSSL)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/lib/tynn/secure_headers.rb
CHANGED
@@ -6,9 +6,9 @@ class Tynn
|
|
6
6
|
# require "tynn"
|
7
7
|
# require "tynn/secure_headers"
|
8
8
|
#
|
9
|
-
# Tynn.
|
9
|
+
# Tynn.plugin(Tynn::SecureHeaders)
|
10
10
|
#
|
11
|
-
# This
|
11
|
+
# This plugin applies the following headers:
|
12
12
|
#
|
13
13
|
# *X-Content-Type-Options:* <tt>"nosniff"</tt>
|
14
14
|
#
|
data/lib/tynn/session.rb
CHANGED
@@ -7,7 +7,7 @@ class Tynn
|
|
7
7
|
# require "tynn"
|
8
8
|
# require "tynn/session"
|
9
9
|
#
|
10
|
-
# Tynn.
|
10
|
+
# Tynn.plugin(Tynn::Session, secret: "__change_me__")
|
11
11
|
#
|
12
12
|
# Tynn.define do
|
13
13
|
# root do
|
@@ -30,7 +30,7 @@ class Tynn
|
|
30
30
|
#
|
31
31
|
# Examples
|
32
32
|
#
|
33
|
-
# Tynn.
|
33
|
+
# Tynn.plugin(Tynn::Session, secret: ENV["SESSION_SECRET"])
|
34
34
|
#
|
35
35
|
# Under the hood, Tynn::Session uses the +Rack::Session::Cookie+ middleware.
|
36
36
|
# Thus, supports all the options available for this middleware:
|
@@ -50,7 +50,7 @@ class Tynn
|
|
50
50
|
#
|
51
51
|
# Examples
|
52
52
|
#
|
53
|
-
# Tynn.
|
53
|
+
# Tynn.plugin(
|
54
54
|
# Tynn::Session,
|
55
55
|
# key: "app",
|
56
56
|
# secret: ENV["SESSION_SECRET"],
|
data/lib/tynn/settings.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Tynn
|
2
|
-
# Public: It provides a settings API for applications. This
|
2
|
+
# Public: It provides a settings API for applications. This plugin is
|
3
3
|
# included by default.
|
4
4
|
#
|
5
5
|
# Examples
|
@@ -18,7 +18,7 @@ class Tynn
|
|
18
18
|
# end
|
19
19
|
# end
|
20
20
|
#
|
21
|
-
# Tynn.
|
21
|
+
# Tynn.plugin(AppName, "MyApp")
|
22
22
|
#
|
23
23
|
# Tynn.app_name
|
24
24
|
# # => "MyApp"
|
data/lib/tynn/static.rb
CHANGED
@@ -7,7 +7,7 @@ class Tynn
|
|
7
7
|
# require "tynn"
|
8
8
|
# require "tynn/static"
|
9
9
|
#
|
10
|
-
# Tynn.
|
10
|
+
# Tynn.plugin(Tynn::Static, ["/js", "/css"])
|
11
11
|
#
|
12
12
|
# By default, serves all requests beginning with the given paths from
|
13
13
|
# the folder +public+ in the current directory (e.g. +public/js/*+,
|
@@ -16,7 +16,7 @@ class Tynn
|
|
16
16
|
#
|
17
17
|
# Examples
|
18
18
|
#
|
19
|
-
# Tynn.
|
19
|
+
# Tynn.plugin(Tynn::Static, ["/js", "/css"], root: "assets")
|
20
20
|
#
|
21
21
|
# Under the hood, it uses the +Rack::Static+ middleware. Thus,
|
22
22
|
# supports all the options available by the middleware. Check
|
@@ -25,7 +25,7 @@ class Tynn
|
|
25
25
|
#
|
26
26
|
# Examples
|
27
27
|
#
|
28
|
-
# Tynn.
|
28
|
+
# Tynn.plugin(Tynn::Static, ["/js", "/css"], index: "index.html")
|
29
29
|
#
|
30
30
|
module Static
|
31
31
|
# Internal: Configures Rack::Static middleware.
|
data/lib/tynn/version.rb
CHANGED
data/test/all_methods_test.rb
CHANGED
data/test/environment_test.rb
CHANGED
@@ -4,7 +4,7 @@ test "use RACK_ENV by default" do
|
|
4
4
|
begin
|
5
5
|
old, ENV["RACK_ENV"] = ENV["RACK_ENV"], "production"
|
6
6
|
|
7
|
-
Tynn.
|
7
|
+
Tynn.plugin(Tynn::Environment)
|
8
8
|
|
9
9
|
assert_equal(:production, Tynn.environment)
|
10
10
|
|
@@ -18,7 +18,7 @@ test "use RACK_ENV by default" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
test "use custom value" do
|
21
|
-
Tynn.
|
21
|
+
Tynn.plugin(Tynn::Environment, env: "development")
|
22
22
|
|
23
23
|
assert_equal(:development, Tynn.environment)
|
24
24
|
assert Tynn.development?
|
data/test/force_ssl_test.rb
CHANGED
@@ -5,7 +5,7 @@ setup do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
test "redirects to https" do |app|
|
8
|
-
Tynn.
|
8
|
+
Tynn.plugin(Tynn::ForceSSL)
|
9
9
|
|
10
10
|
Tynn.define do
|
11
11
|
end
|
@@ -17,7 +17,7 @@ test "redirects to https" do |app|
|
|
17
17
|
end
|
18
18
|
|
19
19
|
test "https request" do |app|
|
20
|
-
Tynn.
|
20
|
+
Tynn.plugin(Tynn::ForceSSL)
|
21
21
|
|
22
22
|
Tynn.define do
|
23
23
|
root do
|
data/test/hmote_test.rb
CHANGED
data/test/hsts_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative "../lib/tynn/hsts"
|
2
2
|
|
3
3
|
test "hsts header" do |app|
|
4
|
-
Tynn.
|
4
|
+
Tynn.plugin(Tynn::HSTS)
|
5
5
|
|
6
6
|
Tynn.define do
|
7
7
|
end
|
@@ -15,7 +15,7 @@ test "hsts header" do |app|
|
|
15
15
|
end
|
16
16
|
|
17
17
|
test "hsts header options" do |app|
|
18
|
-
Tynn.
|
18
|
+
Tynn.plugin(Tynn::HSTS, expires: 1, subdomains: false, preload: true)
|
19
19
|
|
20
20
|
Tynn.define do
|
21
21
|
end
|
data/test/json_test.rb
CHANGED
data/test/matchers_test.rb
CHANGED
data/test/not_found_test.rb
CHANGED
data/test/protection_test.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative "../lib/tynn/session"
|
|
4
4
|
test "supports hsts options" do
|
5
5
|
hsts = { expires: 100, subdomains: false, preload: true }
|
6
6
|
|
7
|
-
Tynn.
|
7
|
+
Tynn.plugin(Tynn::Protection, ssl: true, hsts: hsts)
|
8
8
|
|
9
9
|
Tynn.define do
|
10
10
|
end
|
@@ -18,8 +18,8 @@ test "supports hsts options" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
test "adds secure flag to session cookie" do
|
21
|
-
Tynn.
|
22
|
-
Tynn.
|
21
|
+
Tynn.plugin(Tynn::Protection, ssl: true)
|
22
|
+
Tynn.plugin(Tynn::Session, secret: "_this_must_be_random_")
|
23
23
|
|
24
24
|
Tynn.define do
|
25
25
|
root do
|
data/test/render_test.rb
CHANGED
data/test/secure_headers_test.rb
CHANGED
data/test/session_test.rb
CHANGED
data/test/static_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tynn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodríguez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|