Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
add pom and Mavenfile and revised readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mkristian committed Mar 15, 2011
1 parent cf167a7 commit 2274193
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
target
*.files
*.pom
*~
14 changes: 9 additions & 5 deletions README.textile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
h1. Enforce SSL for you controllers

p. with the advent of hijacking tools for dummies like "firesheep":http://codebutler.github.com/firesheep the need for securing your sessions with ssl is there.
p. with the advent of hijacking tools for dummies like "firesheep":http://codebutler.github.com/firesheep the need for securing your sessions with ssl is there and it is important that every and any request goes over ssl. this plugin does make the server side *secure* by redirecting the browser to the ssl port if not used. the client side there is "HTTP_Strict_Transport_Security (HSTS)":http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security which is implemented by all modern browsers but it relies on a valid (not self-signed) certificate. with that HSTS header in place the browser uses only https requests to communicate with the server.

p. this is derived from the "rails/ssl_requirement":http://github.org/rails/ssl_requirement and adopted a more strict approach: *secure everything and open it where needed*.
p. this gem is derived from the "rails/ssl_requirement":http://github.org/rails/ssl_requirement and adopted a more strict approach: *secure everything and open it where needed*. also it adds HSTS support per default on production - you can turn it off per config.

p. info about the actual gem please look into the directory "enforce-ssl-gem":http://github.org/mkristian/enforce-ssl/tree/master/enforce-ssl-gem

Expand All @@ -12,12 +12,16 @@ p. the "demo":http://github.org/mkristian/enforce-ssl/tree/master/demo is a samp

h2. run all the tests + integrations-tests in one go

p. first you need jruby for this ! then you need to install
p. first you need jruby for this ! then you need to install ruby-maven

bc. jruby -S gem 'ruby-maven'
bc. jruby -S gem install ruby-maven

p. which allows to run the integration-tests from the demo with jetty.

p. now you can execute

bc. rmvn verify
bc. rmvn install

h2. ruby-maven

p. this gem comes with command *jetty-run* which runs a jetty server with a http port and https port so with this you "test" this rails plugin. in case you start the regular webrick on port 3000 (or any other then 8080) will not apply the ssl redirect, so you can develop your application as usual with those server.
4 changes: 4 additions & 0 deletions enforce-ssl-gem/Mavenfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
execute_in_phase(:install) do
puts "hello"
end
properties['jruby.plugins.version'] = '0.25.0-SNAPSHOT'
30 changes: 19 additions & 11 deletions enforce-ssl-gem/README.textile
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
h1. Enforce SSL for you controllers

p. this is derived from the "rails/ssl_requirement":http://github.org/rails/ssl_requirement and adopted a more strict approach: *secure everything and open it where needed*.

p. info about the actual gem please look into the directory "enforce-ssl-gem":http://github.org/mkristian/enforce-ssl/tree/master/enforce-ssl-gem
p. this is derived from the "rails/ssl_requirement":http://github.org/rails/ssl_requirement and adopted a more strict approach: *secure everything and open it when and where needed*.

h2. usage

p. it requires rails2. for installation add the gem in 'Gemfile'
p. it requires rails3. for installation add the gem in _Gemfile_

bc. gem 'enforce-ssl'

p. this activates the 'enforce-ssl' before_filter for all controllers, i.e.
p. this activates the *enforce-ssl* before_filter for all controllers, i.e.
all requests which comes in as http will be redirected to the https url obeying the configured ssl port.

h3. configure the ssl port
h3. configure the ssl/no_ssl port

p. configure the enforced ssl port with (default => { development => 3000, production => 443)
p. configure the enforced ssl port with (default => { development => 8080/8443, production => 80/443)

bc. config.ssl_port = 8443
config.no_ssl_port = 8080

p. for development you can do that in _config/environments/development.rb_.

h3. configure HSTS - HTTP Strict Transport Security

p. there are two config parameters for HSTS: hsts_include_sub_domain (default false) and hsts_max_age (default 31536000 which is one year in seconds).

p. these configuration is *only used during production* so it sufficient to configure it in _config/environments/production.rb_

p. for development you can do that in 'config/environments/development.rb'.
bc. config.hsts_include_sub_domain = false
config.hsts_max_age = 31536000

h3. using a webserver which listens to http + https

p. if your Gemfile allows to JRuby as interpreter then you can use the *jetty-run* from the *ruby-maven* gem (jruby only) to have both an http and an https port listing for requests.
p. if your Gemfile allows to use JRuby as interpreter then you can use the *jetty-run* from the *ruby-maven* gem (jruby only) to have both an http and an https port listing for requests. that is how the defaults are set up.

p. webrick can handle ssl as well here a blog which explains how to get ssl working for "webrick and rails3":http://www.nearinfinity.com/blogs/chris_rohr/configuring_webrick_to_use_ssl.html. but you have *only* ssl then !
p. webrick can handle ssl as well. here a blog which explains how to get ssl working for "webrick and rails3":http://www.nearinfinity.com/blogs/chris_rohr/configuring_webrick_to_use_ssl.html. but you have *only* ssl then and you need to configure the ssl_port correctly.

p. maybe other servers can offer you both ssl and none-ssl . . .
p. maybe other servers can offer both ssl and none-ssl . . .

p. *NOTE*: use *https://* in your url when using the ssl port or webrick with ssl

Expand Down
13 changes: 0 additions & 13 deletions enforce-ssl-gem/enforce-ssl.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,4 @@ Gem::Specification.new do |s|
# s.rdoc_options = ['--main','README.textile']
s.files += Dir['lib/**/*']
s.add_development_dependency 'rake', '0.8.7'

s.post_install_message = <<-TEXT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
configure the enforced ssl port with
(default => { development => 3000, production => 443 }):
config.ssl_port = 8443
for development you can do that in 'config/environments/development.rb'.
you can use 'jetty-run' from 'ruby-maven' gem (jruby only) to have both
an http and an https port listing for requests.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TEXT
end

0 comments on commit 2274193

Please sign in to comment.