lotusrb 0.3.2 → 0.4.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/CHANGELOG.md +20 -0
- data/FEATURES.md +17 -0
- data/README.md +16 -355
- data/lib/lotus.rb +0 -1
- data/lib/lotus/action/csrf_protection.rb +167 -0
- data/lib/lotus/application.rb +3 -1
- data/lib/lotus/cli.rb +14 -13
- data/lib/lotus/commands/console.rb +1 -1
- data/lib/lotus/commands/db.rb +102 -0
- data/lib/lotus/commands/db/abstract.rb +15 -0
- data/lib/lotus/commands/db/apply.rb +14 -0
- data/lib/lotus/commands/db/console.rb +1 -5
- data/lib/lotus/commands/db/create.rb +14 -0
- data/lib/lotus/commands/db/drop.rb +14 -0
- data/lib/lotus/commands/db/migrate.rb +19 -0
- data/lib/lotus/commands/db/prepare.rb +14 -0
- data/lib/lotus/commands/db/version.rb +14 -0
- data/lib/lotus/commands/generate.rb +20 -20
- data/lib/lotus/commands/new.rb +1 -0
- data/lib/lotus/commands/routes.rb +1 -2
- data/lib/lotus/configuration.rb +29 -0
- data/lib/lotus/container.rb +19 -3
- data/lib/lotus/environment.rb +62 -9
- data/lib/lotus/frameworks.rb +1 -0
- data/lib/lotus/generators/action.rb +46 -10
- data/lib/lotus/generators/action/action_spec.minitest.tt +1 -1
- data/lib/lotus/generators/action/action_spec.rspec.tt +1 -1
- data/lib/lotus/generators/action/view_spec.minitest.tt +2 -1
- data/lib/lotus/generators/action/view_spec.rspec.tt +2 -1
- data/lib/lotus/generators/app.rb +39 -0
- data/lib/lotus/generators/app/.gitkeep +1 -0
- data/lib/lotus/generators/application/app.rb +184 -0
- data/lib/lotus/generators/application/app/.env.development.tt +3 -0
- data/lib/lotus/generators/application/app/.env.test.tt +3 -0
- data/lib/lotus/generators/application/{container/config → app}/.env.tt +0 -0
- data/lib/lotus/generators/application/app/.gitkeep +1 -0
- data/lib/lotus/generators/application/app/Gemfile.tt +35 -0
- data/lib/lotus/generators/application/app/Rakefile.minitest.tt +10 -0
- data/lib/lotus/generators/application/app/Rakefile.rspec.tt +5 -0
- data/lib/lotus/generators/application/app/apps/.gitkeep.tt +1 -0
- data/lib/lotus/generators/application/app/capybara.rb.rspec.tt +8 -0
- data/lib/lotus/generators/application/app/config.ru.tt +3 -0
- data/lib/lotus/generators/application/app/config/application.rb.tt +227 -0
- data/lib/lotus/generators/application/app/config/environment.rb.tt +5 -0
- data/lib/lotus/generators/application/app/config/routes.rb.tt +2 -0
- data/lib/lotus/generators/application/app/db/.gitkeep +1 -0
- data/lib/lotus/generators/application/app/features_helper.rb.minitest.tt +11 -0
- data/lib/lotus/generators/application/app/features_helper.rb.rspec.tt +12 -0
- data/lib/lotus/generators/application/app/gitignore.tt +2 -0
- data/lib/lotus/generators/application/app/lib/app_name.rb.tt +47 -0
- data/lib/lotus/generators/application/app/lib/chirp/entities/.gitkeep +1 -0
- data/lib/lotus/generators/application/app/lib/chirp/repositories/.gitkeep +1 -0
- data/lib/lotus/generators/application/app/lib/config/mapping.rb.tt +7 -0
- data/lib/lotus/generators/application/app/lotusrc.tt +3 -0
- data/lib/lotus/generators/application/app/rspec.rspec.tt +2 -0
- data/lib/lotus/generators/application/app/schema.sql.tt +0 -0
- data/lib/lotus/generators/application/app/spec_helper.rb.minitest.tt +7 -0
- data/lib/lotus/generators/application/app/spec_helper.rb.rspec.tt +100 -0
- data/lib/lotus/generators/application/app/templates/application.html.erb.tt +9 -0
- data/lib/lotus/generators/application/app/views/application_layout.rb.tt +7 -0
- data/lib/lotus/generators/application/container.rb +37 -13
- data/lib/lotus/generators/application/container/{config/.env.development.tt → .env.development.tt} +0 -0
- data/lib/lotus/generators/application/container/{config/.env.test.tt → .env.test.tt} +0 -0
- data/lib/lotus/generators/application/container/.env.tt +1 -0
- data/lib/lotus/generators/application/container/lib/app_name.rb.tt +9 -0
- data/lib/lotus/generators/application/container/schema.sql.tt +0 -0
- data/lib/lotus/generators/migration.rb +58 -0
- data/lib/lotus/generators/migration/migration.rb.tt +4 -0
- data/lib/lotus/generators/model.rb +10 -7
- data/lib/lotus/generators/slice.rb +4 -12
- data/lib/lotus/generators/slice/application.rb.tt +3 -19
- data/lib/lotus/generators/slice/config/routes.rb.tt +1 -7
- data/lib/lotus/loader.rb +15 -1
- data/lib/lotus/lotusrc.rb +8 -3
- data/lib/lotus/templates/{welcome.html → welcome.html.erb} +4 -3
- data/lib/lotus/version.rb +1 -1
- data/lib/lotus/welcome.rb +20 -1
- data/lotusrb.gemspec +5 -5
- metadata +67 -18
- data/lib/lotus/generators/slice/action.rb.tt +0 -8
- data/lib/lotus/generators/slice/config/mapping.rb.tt +0 -13
- data/lib/lotus/generators/slice/templates/template.html.erb.tt +0 -2
- data/lib/lotus/generators/slice/view.rb.tt +0 -5
- data/lib/lotus/logger.rb +0 -141
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require_relative '
|
2
|
+
require_relative '<%= config[:relative_view_path] %>'
|
3
3
|
|
4
4
|
describe <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %> do
|
5
5
|
let(:exposures) { Hash[foo: 'bar'] }
|
6
6
|
let(:template) { Lotus::View::Template.new('<%= config[:template_path] %>') }
|
7
7
|
let(:view) { <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %>.new(template, exposures) }
|
8
|
+
let(:rendered) { view.render }
|
8
9
|
|
9
10
|
it "exposes #foo" do
|
10
11
|
view.foo.must_equal exposures.fetch(:foo)
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require_relative '
|
2
|
+
require_relative '<%= config[:relative_view_path] %>'
|
3
3
|
|
4
4
|
describe <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %> do
|
5
5
|
let(:exposures) { Hash[foo: 'bar'] }
|
6
6
|
let(:template) { Lotus::View::Template.new('<%= config[:template_path] %>') }
|
7
7
|
let(:view) { <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %>.new(template, exposures) }
|
8
|
+
let(:rendered) { view.render }
|
8
9
|
|
9
10
|
it "exposes #foo" do
|
10
11
|
expect(view.foo).to eq exposures.fetch(:foo)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
require 'lotus/generators/abstract'
|
3
|
+
require 'lotus/generators/slice'
|
4
|
+
|
5
|
+
module Lotus
|
6
|
+
module Generators
|
7
|
+
class App < Abstract
|
8
|
+
def initialize(command)
|
9
|
+
super
|
10
|
+
|
11
|
+
options.merge!(app_name_options)
|
12
|
+
@slice_generator = Slice.new(command)
|
13
|
+
|
14
|
+
cli.class.source_root(source)
|
15
|
+
end
|
16
|
+
|
17
|
+
def start
|
18
|
+
@slice_generator.start
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# @since 0.4.0
|
24
|
+
# @api private
|
25
|
+
def app_name_options
|
26
|
+
{
|
27
|
+
application: app_name,
|
28
|
+
application_base_url: application_base_url
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# @since 0.4.0
|
33
|
+
# @api private
|
34
|
+
def application_base_url
|
35
|
+
options[:application_base_url] || "/#{app_name}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
require 'lotus/generators/abstract'
|
3
|
+
|
4
|
+
module Lotus
|
5
|
+
module Generators
|
6
|
+
module Application
|
7
|
+
class App < Abstract
|
8
|
+
def initialize(command)
|
9
|
+
super
|
10
|
+
|
11
|
+
@upcase_app_name = app_name.to_env_s
|
12
|
+
@classified_app_name = Utils::String.new(app_name).classify
|
13
|
+
@lotus_head = options.fetch(:lotus_head)
|
14
|
+
@test = options[:test]
|
15
|
+
@database = options[:database]
|
16
|
+
@application_base_url = options[:application_base_url]
|
17
|
+
@lotus_model_version = '~> 0.4'
|
18
|
+
|
19
|
+
cli.class.source_root(source)
|
20
|
+
end
|
21
|
+
|
22
|
+
def start
|
23
|
+
|
24
|
+
opts = {
|
25
|
+
app_name: app_name,
|
26
|
+
upcase_app_name: @upcase_app_name,
|
27
|
+
classified_app_name: @classified_app_name,
|
28
|
+
application_base_url: @application_base_url,
|
29
|
+
lotus_head: @lotus_head,
|
30
|
+
test: @test,
|
31
|
+
database: @database,
|
32
|
+
database_config: database_config,
|
33
|
+
lotus_model_version: @lotus_model_version,
|
34
|
+
}
|
35
|
+
|
36
|
+
templates = {
|
37
|
+
'lotusrc.tt' => '.lotusrc',
|
38
|
+
'.env.tt' => '.env',
|
39
|
+
'.env.development.tt' => '.env.development',
|
40
|
+
'.env.test.tt' => '.env.test',
|
41
|
+
'Gemfile.tt' => 'Gemfile',
|
42
|
+
'config.ru.tt' => 'config.ru',
|
43
|
+
'config/environment.rb.tt' => 'config/environment.rb',
|
44
|
+
'lib/app_name.rb.tt' => "lib/#{ app_name }.rb",
|
45
|
+
'lib/config/mapping.rb.tt' => 'lib/config/mapping.rb',
|
46
|
+
'config/application.rb.tt' => 'config/application.rb',
|
47
|
+
'config/routes.rb.tt' => 'config/routes.rb',
|
48
|
+
'views/application_layout.rb.tt' => 'app/views/application_layout.rb',
|
49
|
+
'templates/application.html.erb.tt' => 'app/templates/application.html.erb',
|
50
|
+
}
|
51
|
+
|
52
|
+
empty_directories = [
|
53
|
+
"app/controllers",
|
54
|
+
"app/views",
|
55
|
+
"lib/#{ app_name }/entities",
|
56
|
+
"lib/#{ app_name }/repositories",
|
57
|
+
"public/javascripts",
|
58
|
+
"public/stylesheets"
|
59
|
+
]
|
60
|
+
|
61
|
+
empty_directories << if sql_database?
|
62
|
+
"db/migrations"
|
63
|
+
else
|
64
|
+
"db"
|
65
|
+
end
|
66
|
+
|
67
|
+
# Add testing directories (spec/ is the default for both MiniTest and RSpec)
|
68
|
+
empty_directories << [
|
69
|
+
"spec/features",
|
70
|
+
"spec/controllers",
|
71
|
+
"spec/views"
|
72
|
+
]
|
73
|
+
|
74
|
+
case options[:test]
|
75
|
+
when 'rspec'
|
76
|
+
templates.merge!(
|
77
|
+
'Rakefile.rspec.tt' => 'Rakefile',
|
78
|
+
'rspec.rspec.tt' => '.rspec',
|
79
|
+
'spec_helper.rb.rspec.tt' => 'spec/spec_helper.rb',
|
80
|
+
'features_helper.rb.rspec.tt' => 'spec/features_helper.rb',
|
81
|
+
'capybara.rb.rspec.tt' => 'spec/support/capybara.rb'
|
82
|
+
)
|
83
|
+
else # minitest (default)
|
84
|
+
templates.merge!(
|
85
|
+
'Rakefile.minitest.tt' => 'Rakefile',
|
86
|
+
'spec_helper.rb.minitest.tt' => 'spec/spec_helper.rb',
|
87
|
+
'features_helper.rb.minitest.tt' => 'spec/features_helper.rb'
|
88
|
+
)
|
89
|
+
end
|
90
|
+
|
91
|
+
empty_directories << [
|
92
|
+
"spec/#{ app_name }/entities",
|
93
|
+
"spec/#{ app_name }/repositories",
|
94
|
+
"spec/support"
|
95
|
+
]
|
96
|
+
|
97
|
+
if sql_database?
|
98
|
+
templates.merge!(
|
99
|
+
'schema.sql.tt' => 'db/schema.sql'
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
templates.each do |src, dst|
|
104
|
+
cli.template(source.join(src), target.join(dst), opts)
|
105
|
+
end
|
106
|
+
|
107
|
+
empty_directories.flatten.each do |dir|
|
108
|
+
gitkeep = '.gitkeep'
|
109
|
+
cli.template(source.join(gitkeep), target.join(dir, gitkeep), opts)
|
110
|
+
end
|
111
|
+
|
112
|
+
unless git_dir_present?
|
113
|
+
cli.template(source.join('gitignore.tt'), target.join('.gitignore'), opts)
|
114
|
+
cli.run("git init #{Shellwords.escape(target)}", capture: true)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
def git_dir_present?
|
121
|
+
File.directory?(source.join('.git'))
|
122
|
+
end
|
123
|
+
|
124
|
+
def database_config
|
125
|
+
{
|
126
|
+
gem: database_gem,
|
127
|
+
uri: database_uri,
|
128
|
+
type: database_type
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
132
|
+
def database_gem
|
133
|
+
{
|
134
|
+
'mysql' => 'mysql',
|
135
|
+
'mysql2' => 'mysql2',
|
136
|
+
'postgresql' => 'pg',
|
137
|
+
'postgres' => 'pg',
|
138
|
+
'sqlite' => 'sqlite3',
|
139
|
+
'sqlite3' => 'sqlite3'
|
140
|
+
}[@database]
|
141
|
+
end
|
142
|
+
|
143
|
+
def sql_database?
|
144
|
+
database_type == :sql
|
145
|
+
end
|
146
|
+
|
147
|
+
def database_type
|
148
|
+
case @database
|
149
|
+
when 'mysql', 'mysql2', 'postgresql', 'postgres', 'sqlite', 'sqlite3'
|
150
|
+
:sql
|
151
|
+
when 'filesystem'
|
152
|
+
:file_system
|
153
|
+
when 'memory'
|
154
|
+
:memory
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def database_uri
|
159
|
+
{
|
160
|
+
development: "#{database_base_uri}_development",
|
161
|
+
test: "#{database_base_uri}_test"
|
162
|
+
}
|
163
|
+
end
|
164
|
+
|
165
|
+
def database_base_uri
|
166
|
+
case @database
|
167
|
+
when 'mysql'
|
168
|
+
"mysql://localhost/#{app_name}"
|
169
|
+
when 'mysql2'
|
170
|
+
"mysql2://localhost/#{app_name}"
|
171
|
+
when 'postgresql', 'postgres'
|
172
|
+
"postgres://localhost/#{app_name}"
|
173
|
+
when 'sqlite', 'sqlite3'
|
174
|
+
"sqlite://db/#{Shellwords.escape(app_name)}"
|
175
|
+
when 'memory'
|
176
|
+
"memory://localhost/#{app_name}"
|
177
|
+
else
|
178
|
+
"file:///db/#{app_name}"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1,35 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'bundler'
|
4
|
+
gem 'rake'
|
5
|
+
|
6
|
+
<%- if config[:lotus_head] -%>
|
7
|
+
gem 'lotus-utils', require: false, github: 'lotus/utils'
|
8
|
+
gem 'lotus-router', require: false, github: 'lotus/router'
|
9
|
+
gem 'lotus-validations', require: false, github: 'lotus/validations'
|
10
|
+
gem 'lotus-helpers', require: false, github: 'lotus/helpers'
|
11
|
+
gem 'lotus-controller', require: false, github: 'lotus/controller'
|
12
|
+
gem 'lotus-view', require: false, github: 'lotus/view'
|
13
|
+
gem 'lotus-model', require: false, github: 'lotus/model'
|
14
|
+
gem 'lotusrb', github: 'lotus/lotus'
|
15
|
+
<%- else -%>
|
16
|
+
gem 'lotusrb', '<%= Lotus::VERSION %>'
|
17
|
+
gem 'lotus-model', '<%= config[:lotus_model_version] %>'
|
18
|
+
<%- end -%>
|
19
|
+
|
20
|
+
<%- if config[:database_config][:gem] %>
|
21
|
+
gem '<%= config[:database_config][:gem] %>'
|
22
|
+
<%- end -%>
|
23
|
+
|
24
|
+
group :test do
|
25
|
+
<%- if config[:test] == 'rspec' -%>
|
26
|
+
gem 'rspec'
|
27
|
+
<%- else -%>
|
28
|
+
gem 'minitest'
|
29
|
+
<%- end -%>
|
30
|
+
gem 'capybara'
|
31
|
+
end
|
32
|
+
|
33
|
+
group :production do
|
34
|
+
# gem 'puma'
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1,227 @@
|
|
1
|
+
require 'lotus/helpers'
|
2
|
+
|
3
|
+
module <%= config[:classified_app_name] %>
|
4
|
+
class Application < Lotus::Application
|
5
|
+
configure do
|
6
|
+
##
|
7
|
+
# BASIC
|
8
|
+
#
|
9
|
+
|
10
|
+
# Define the root path of this application.
|
11
|
+
# All paths specified in this configuration are relative to path below.
|
12
|
+
#
|
13
|
+
root "#{ __dir__ }/.."
|
14
|
+
|
15
|
+
# Relative load paths where this application will recursively load the code.
|
16
|
+
# When you add new directories, remember to add them here.
|
17
|
+
#
|
18
|
+
load_paths << [
|
19
|
+
'app/controllers',
|
20
|
+
'app/views'
|
21
|
+
]
|
22
|
+
|
23
|
+
# Handle exceptions with HTTP statuses (true) or don't catch them (false).
|
24
|
+
# Defaults to true.
|
25
|
+
# See: http://www.rubydoc.info/gems/lotus-controller/
|
26
|
+
|
27
|
+
# Exceptions_management
|
28
|
+
#
|
29
|
+
# handle_exceptions true
|
30
|
+
|
31
|
+
##
|
32
|
+
# HTTP
|
33
|
+
#
|
34
|
+
|
35
|
+
# Routes definitions for this application
|
36
|
+
# See: http://www.rubydoc.info/gems/lotus-router#Usage
|
37
|
+
#
|
38
|
+
routes 'config/routes'
|
39
|
+
|
40
|
+
# URI scheme used by the routing system to generate absolute URLs
|
41
|
+
# Defaults to "http"
|
42
|
+
#
|
43
|
+
# scheme 'https'
|
44
|
+
|
45
|
+
# URI host used by the routing system to generate absolute URLs
|
46
|
+
# Defaults to "localhost"
|
47
|
+
#
|
48
|
+
# host 'example.org'
|
49
|
+
|
50
|
+
# URI port used by the routing system to generate absolute URLs
|
51
|
+
# Argument: An object coercible to integer, default to 80 if the scheme is http and 443 if it's https
|
52
|
+
# This SHOULD be configured only in case the application listens to that non standard ports
|
53
|
+
#
|
54
|
+
# port 443
|
55
|
+
|
56
|
+
# Enable cookies
|
57
|
+
# Argument: boolean to toggle the feature
|
58
|
+
# A Hash with options
|
59
|
+
#
|
60
|
+
# Options: :domain - The domain (String - nil by default, not required)
|
61
|
+
# :path - Restrict cookies to a relative URI (String - nil by default)
|
62
|
+
# :max_age - Cookies expiration expressed in seconds (Integer - nil by default)
|
63
|
+
# :secure - Restrict cookies to secure connections
|
64
|
+
# (Boolean - Automatically set on true if currenlty using a secure connection)
|
65
|
+
# See #scheme and #ssl?
|
66
|
+
# :httponly - Prevent JavaScript access (Boolean - true by default)
|
67
|
+
#
|
68
|
+
# cookies true
|
69
|
+
# or
|
70
|
+
# cookies max_age: 300
|
71
|
+
|
72
|
+
# Enable sessions
|
73
|
+
# Argument: Symbol the Rack session adapter
|
74
|
+
# A Hash with options
|
75
|
+
#
|
76
|
+
# See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
|
77
|
+
#
|
78
|
+
# sessions :cookie, secret: ENV['<%= config[:upcase_app_name] %>_SESSIONS_SECRET']
|
79
|
+
|
80
|
+
# Configure Rack middleware for this application
|
81
|
+
#
|
82
|
+
# middleware.use Rack::Protection
|
83
|
+
|
84
|
+
# Default format for the requests that don't specify an HTTP_ACCEPT header
|
85
|
+
# Argument: A symbol representation of a mime type, default to :html
|
86
|
+
#
|
87
|
+
# default_format :html
|
88
|
+
|
89
|
+
# HTTP Body parsers
|
90
|
+
# Parse non GET responses body for a specific mime type
|
91
|
+
# Argument: Symbol, which represent the format of the mime type (only `:json` is supported)
|
92
|
+
# Object, the parser
|
93
|
+
#
|
94
|
+
# body_parsers :json
|
95
|
+
|
96
|
+
##
|
97
|
+
# TEMPLATES
|
98
|
+
#
|
99
|
+
|
100
|
+
# The layout to be used by all views
|
101
|
+
#
|
102
|
+
layout :application # It will load <%= config[:classified_app_name] %>::Views::ApplicationLayout
|
103
|
+
|
104
|
+
# The relative path to templates
|
105
|
+
#
|
106
|
+
templates 'app/templates'
|
107
|
+
|
108
|
+
##
|
109
|
+
# ASSETS
|
110
|
+
#
|
111
|
+
|
112
|
+
# Specify sources for assets
|
113
|
+
# The directory `public/` is added by default
|
114
|
+
#
|
115
|
+
# assets << [
|
116
|
+
# 'vendor/javascripts'
|
117
|
+
# ]
|
118
|
+
|
119
|
+
# Enabling serving assets
|
120
|
+
# Defaults to false
|
121
|
+
#
|
122
|
+
# serve_assets false
|
123
|
+
|
124
|
+
##
|
125
|
+
# SECURITY
|
126
|
+
#
|
127
|
+
|
128
|
+
# X-Frame-Options is a HTTP header supported by modern browsers.
|
129
|
+
# It determines if a web page can or cannot be included via <frame> and
|
130
|
+
# <iframe> tags by untrusted domains.
|
131
|
+
#
|
132
|
+
# Web applications can send this header to prevent Clickjacking attacks.
|
133
|
+
#
|
134
|
+
# Read more at:
|
135
|
+
#
|
136
|
+
# * https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options
|
137
|
+
# * https://www.owasp.org/index.php/Clickjacking
|
138
|
+
#
|
139
|
+
security.x_frame_options "DENY"
|
140
|
+
|
141
|
+
# Content-Security-Policy (CSP) is a HTTP header supported by modern browsers.
|
142
|
+
# It determines trusted sources of execution for dynamic contents
|
143
|
+
# (JavaScript) or other web related assets: stylesheets, images, fonts,
|
144
|
+
# plugins, etc.
|
145
|
+
#
|
146
|
+
# Web applications can send this header to mitigate Cross Site Scripting
|
147
|
+
# (XSS) attacks.
|
148
|
+
#
|
149
|
+
# The default value allows images, scripts, AJAX, and CSS from the same
|
150
|
+
# origin, and does not allow any other resources to load (eg object,
|
151
|
+
# frame, media, etc).
|
152
|
+
#
|
153
|
+
# Inline JavaScript is NOT allowed. To enable it, please use:
|
154
|
+
# "script-src 'unsafe-inline'".
|
155
|
+
#
|
156
|
+
# Content Security Policy introduction:
|
157
|
+
#
|
158
|
+
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
159
|
+
# * https://www.owasp.org/index.php/Content_Security_Policy
|
160
|
+
# * https://www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29
|
161
|
+
#
|
162
|
+
# Inline and eval JavaScript risks:
|
163
|
+
#
|
164
|
+
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful
|
165
|
+
# * http://www.html5rocks.com/en/tutorials/security/content-security-policy/#eval-too
|
166
|
+
#
|
167
|
+
# Content Security Policy usage:
|
168
|
+
#
|
169
|
+
# * http://content-security-policy.com/
|
170
|
+
# * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Using_Content_Security_Policy
|
171
|
+
#
|
172
|
+
security.content_security_policy "default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';"
|
173
|
+
|
174
|
+
##
|
175
|
+
# FRAMEWORKS
|
176
|
+
#
|
177
|
+
|
178
|
+
# Configure the code that will yield each time <%= config[:classified_app_name] %>::Action is included
|
179
|
+
# This is useful for sharing common functionality
|
180
|
+
#
|
181
|
+
# See: http://www.rubydoc.info/gems/lotus-controller#Configuration
|
182
|
+
controller.prepare do
|
183
|
+
# include MyAuthentication # included in all the actions
|
184
|
+
# before :authenticate! # run an authentication before callback
|
185
|
+
end
|
186
|
+
|
187
|
+
# Configure the code that will yield each time <%= config[:classified_app_name] %>::View is included
|
188
|
+
# This is useful for sharing common functionality
|
189
|
+
#
|
190
|
+
# See: http://www.rubydoc.info/gems/lotus-view#Configuration
|
191
|
+
view.prepare do
|
192
|
+
include Lotus::Helpers
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
##
|
197
|
+
# DEVELOPMENT
|
198
|
+
#
|
199
|
+
configure :development do
|
200
|
+
# Don't handle exceptions, render the stack trace
|
201
|
+
handle_exceptions false
|
202
|
+
|
203
|
+
# Serve static assets during development
|
204
|
+
serve_assets true
|
205
|
+
end
|
206
|
+
|
207
|
+
##
|
208
|
+
# TEST
|
209
|
+
#
|
210
|
+
configure :test do
|
211
|
+
# Don't handle exceptions, render the stack trace
|
212
|
+
handle_exceptions false
|
213
|
+
|
214
|
+
# Serve static assets during development
|
215
|
+
serve_assets true
|
216
|
+
end
|
217
|
+
|
218
|
+
##
|
219
|
+
# PRODUCTION
|
220
|
+
#
|
221
|
+
configure :production do
|
222
|
+
# scheme 'https'
|
223
|
+
# host 'example.org'
|
224
|
+
# port 443
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|