ixtlan-core 0.1.1 → 0.2.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.
- data/MIT-LICENSE +20 -0
- data/lib/generators/ixtlan/setup/templates/application_layout.html.erb +1 -1
- data/lib/generators/scaffold_controller/templates/controller.rb +1 -1
- data/lib/ixtlan/core/cache_headers.rb +3 -10
- data/lib/ixtlan/core/extra_headers.rb +29 -0
- data/lib/ixtlan/core/railtie.rb +12 -0
- data/lib/ixtlan/core/x_frame_headers.rb +29 -0
- metadata +19 -7
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Kristian Meier
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<%%= javascript_include_tag :defaults %>
|
7
7
|
<%%= csrf_meta_tag %>
|
8
8
|
<%% if controller.respond_to?(:current_user) && controller.send(:current_user) != nil %>
|
9
|
-
<meta
|
9
|
+
<meta http-equiv="refresh" content="<%%= controller.send(:idle_session_timeout) * 60 + 5 %>" />
|
10
10
|
<%% end %>
|
11
11
|
</head>
|
12
12
|
<body>
|
@@ -40,7 +40,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
40
40
|
# POST <%= route_url %>.json
|
41
41
|
def create
|
42
42
|
@<%= singular_table_name %> = <%= orm_class.build(class_name, "params[:#{singular_table_name}]") %>
|
43
|
-
<%
|
43
|
+
<% if options[:modified_by] -%>
|
44
44
|
@<%= singular_table_name %>.current_user = current_user
|
45
45
|
<% end -%>
|
46
46
|
|
@@ -42,7 +42,7 @@ module Ixtlan
|
|
42
42
|
|
43
43
|
def cache_headers
|
44
44
|
if(respond_to?(:current_user) && current_user)
|
45
|
-
mode = self.class.instance_variable_get(:@
|
45
|
+
mode = self.class.instance_variable_get(:@_cache_mode)
|
46
46
|
case mode
|
47
47
|
when :private
|
48
48
|
no_caching(self.class.instance_variable_get(:@no_store))
|
@@ -53,8 +53,6 @@ module Ixtlan
|
|
53
53
|
else
|
54
54
|
send mode if mode
|
55
55
|
end
|
56
|
-
# else
|
57
|
-
# allow_browser_and_proxy_to_cache(self.class.instance_variable_get(:@no_store))
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
@@ -62,21 +60,16 @@ module Ixtlan
|
|
62
60
|
base.class_eval do
|
63
61
|
def self.cache_headers(mode = nil, no_store = true)
|
64
62
|
if(mode)
|
65
|
-
@
|
63
|
+
@_cache_mode = mode.to_sym
|
66
64
|
end
|
67
65
|
@no_store = no_store
|
68
66
|
end
|
69
|
-
alias :render_old :render
|
70
|
-
def render(*args)
|
71
|
-
cache_headers
|
72
|
-
render_old(*args)
|
73
|
-
end
|
74
67
|
end
|
75
68
|
end
|
76
69
|
|
77
70
|
private
|
78
71
|
def cachable_response?
|
79
|
-
request.method ==
|
72
|
+
request.method.to_s.downcase == "get" &&
|
80
73
|
[200, 203, 206, 300, 301].member?(response.status)
|
81
74
|
end
|
82
75
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ixtlan
|
2
|
+
module Core
|
3
|
+
module ExtraHeaders
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
alias :render_old :render
|
8
|
+
def render(*args, &block)
|
9
|
+
cache_headers
|
10
|
+
x_frame_headers
|
11
|
+
render_old(*args, &block)
|
12
|
+
end
|
13
|
+
alias :send_file_old :send_file
|
14
|
+
def send_file(*args)
|
15
|
+
cache_headers
|
16
|
+
x_frame_headers
|
17
|
+
send_file_old(*args)
|
18
|
+
end
|
19
|
+
alias :send_data_old :send_data
|
20
|
+
def send_data(*args)
|
21
|
+
cache_headers
|
22
|
+
x_frame_headers
|
23
|
+
send_file_old(*args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/ixtlan/core/railtie.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
require 'ixtlan/core/extra_headers'
|
1
2
|
require 'ixtlan/core/cache_headers'
|
3
|
+
require 'ixtlan/core/x_frame_headers'
|
2
4
|
require 'ixtlan/core/configuration_rack'
|
3
5
|
require 'ixtlan/core/configuration_manager'
|
4
6
|
|
@@ -31,6 +33,13 @@ module Ixtlan
|
|
31
33
|
ActiveRecord::Generators::ModelGenerator.class_option :singleton, :type => :boolean, :default => false
|
32
34
|
end
|
33
35
|
|
36
|
+
config.before_configuration do |app|
|
37
|
+
app.config.class.class_eval do
|
38
|
+
attr_accessor :x_frame_headers
|
39
|
+
end
|
40
|
+
app.config.x_frame_headers = :deny
|
41
|
+
end
|
42
|
+
|
34
43
|
config.before_initialize do |app|
|
35
44
|
app.config.class.class_eval do
|
36
45
|
attr_accessor :configuration_model
|
@@ -39,7 +48,10 @@ module Ixtlan
|
|
39
48
|
@configuration_model = clazz
|
40
49
|
end
|
41
50
|
end
|
51
|
+
::ActionController::Base.send(:include, Ixtlan::Core::ExtraHeaders)
|
52
|
+
::ActionController::Base.send(:include, Ixtlan::Core::XFrameHeaders)
|
42
53
|
::ActionController::Base.send(:include, Ixtlan::Core::CacheHeaders)
|
54
|
+
|
43
55
|
app.config.middleware.use Ixtlan::Core::ConfigurationRack
|
44
56
|
end
|
45
57
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ixtlan
|
2
|
+
module Core
|
3
|
+
module XFrameHeaders
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def x_frame_headers
|
8
|
+
case self.class.instance_variable_get(:@_x_frame_mode) || Rails.configuration.x_frame_headers
|
9
|
+
when :deny
|
10
|
+
response.headers["X-FRAME-OPTIONS"] = "DENY"
|
11
|
+
when :sameorigin
|
12
|
+
response.headers["X-FRAME-OPTIONS"] = "SAMEORIGIN"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.included(base)
|
17
|
+
base.class_eval do
|
18
|
+
def self.x_frame_headers(mode)
|
19
|
+
if(mode)
|
20
|
+
@_x_frame_mode = mode.to_sym
|
21
|
+
else
|
22
|
+
@_x_frame_mode = nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- mkristian
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-03
|
17
|
+
date: 2011-04-03 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -22,13 +22,20 @@ dependencies:
|
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
segments:
|
28
28
|
- 0
|
29
29
|
- 4
|
30
30
|
- 2
|
31
31
|
version: 0.4.2
|
32
|
+
- - <
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
segments:
|
35
|
+
- 0
|
36
|
+
- 4
|
37
|
+
- 99999
|
38
|
+
version: 0.4.99999
|
32
39
|
type: :runtime
|
33
40
|
version_requirements: *id001
|
34
41
|
- !ruby/object:Gem::Dependency
|
@@ -86,8 +93,10 @@ dependencies:
|
|
86
93
|
- 3
|
87
94
|
- 0
|
88
95
|
- 2
|
89
|
-
-
|
90
|
-
|
96
|
+
- 0
|
97
|
+
- 26
|
98
|
+
- 0
|
99
|
+
version: 0.8.3.0.2.0.26.0
|
91
100
|
type: :development
|
92
101
|
version_requirements: *id005
|
93
102
|
description: base for some gems related to protect privacy and increase security along some other utils
|
@@ -100,6 +109,7 @@ extensions: []
|
|
100
109
|
extra_rdoc_files: []
|
101
110
|
|
102
111
|
files:
|
112
|
+
- MIT-LICENSE
|
103
113
|
- lib/ixtlan-core.rb
|
104
114
|
- lib/generators/model/model_generator.rb
|
105
115
|
- lib/generators/scaffold/scaffold_generator.rb
|
@@ -126,6 +136,8 @@ files:
|
|
126
136
|
- lib/generators/rails/templates/edit.html.erb
|
127
137
|
- lib/generators/rails/templates/migration.rb
|
128
138
|
- lib/generators/rails/templates/_form.html.erb
|
139
|
+
- lib/ixtlan/core/extra_headers.rb
|
140
|
+
- lib/ixtlan/core/x_frame_headers.rb
|
129
141
|
- lib/ixtlan/core/railtie.rb
|
130
142
|
- lib/ixtlan/core/configuration_manager.rb
|
131
143
|
- lib/ixtlan/core/cache_headers.rb
|