SSL Requirement plugin

Is there any way to have the plugin require SSL to be used for all
actions in a controller and just specify the ones you dont want to
require SSL using ssl_allowed?

class ApplicationController < ActiveRecord::Base
include SslRequirement
ssl_required .

Many thanks.

Also I could of course combine this with local.request? so that when
developing locally http is allowed, but when in production the
ssl_required kicks in.

Here’s how I’m doing it:

before_filter :require_ssl, :except => [:some_action, :other_action]

def require_ssl
if !@request.ssl?
redirect_to :protocol => “https://”

On 3/30/06, Peter P. [email protected] wrote:

You could also chain a statement for local requests - something like:

if !@requst.ssl? and !@requiest.local

On 3/30/06, Michael G. [email protected] wrote:

On 3/30/06, Peter P. [email protected] wrote:

Thanks Michael, Are you not using the SSL_require plugin then, just
doing your own version, looks pretty stright forward!

I have similar:

Adds a filter that requires ssl.

def self.require_ssl(options={})
before_filter :require_ssl, options

def require_ssl
if ENV[‘RAILS_SSL’] == ‘on’
request.env[‘HTTPS’] = ‘on’
raise SSLRequiredError if !request.ssl?

Then in controllers:

require_ssl :only => ‘login’


This way I can set an environment variable to turn it on or off and
rather than redirecting it actually raises an exception. Just a

On 3/31/06, Peter [email protected] wrote:

Dan W.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs