Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 43 lines (32 sloc) 1.231 kb
79ded84 @dhh SSL requirement adds a declarative way of specifying that certain act…
dhh authored
1 SSL Requirement
2 ===============
3
aa2dded @jamis [ssl_requirement plugin] add unit tests and ssl_allowed option (for a…
jamis authored
4 SSL requirement adds a declarative way of specifying that certain actions
5 should only be allowed to run under SSL, and if they're accessed without it,
6 they should be redirected.
79ded84 @dhh SSL requirement adds a declarative way of specifying that certain act…
dhh authored
7
8 Example:
9
10 class ApplicationController < ActiveRecord::Base
11 include SslRequirement
12 end
13
14 class AccountController < ApplicationController
15 ssl_required :signup, :payment
aa2dded @jamis [ssl_requirement plugin] add unit tests and ssl_allowed option (for a…
jamis authored
16 ssl_allowed :index
79ded84 @dhh SSL requirement adds a declarative way of specifying that certain act…
dhh authored
17
18 def signup
19 # Non-SSL access will be redirected to SSL
20 end
21
22 def payment
23 # Non-SSL access will be redirected to SSL
24 end
aa2dded @jamis [ssl_requirement plugin] add unit tests and ssl_allowed option (for a…
jamis authored
25
26 def index
27 # This action will work either with or without SSL
28 end
29
30 def other
31 # SSL access will be redirected to non-SSL
32 end
79ded84 @dhh SSL requirement adds a declarative way of specifying that certain act…
dhh authored
33 end
34
aa2dded @jamis [ssl_requirement plugin] add unit tests and ssl_allowed option (for a…
jamis authored
35 You can overwrite the protected method ssl_required? to rely on other things
36 than just the declarative specification. Say, only premium accounts get SSL.
79ded84 @dhh SSL requirement adds a declarative way of specifying that certain act…
dhh authored
37
aa2dded @jamis [ssl_requirement plugin] add unit tests and ssl_allowed option (for a…
jamis authored
38 P.S.: Beware when you include the SslRequirement module. At the time of
39 inclusion, it'll add the before_filter that validates the declarations. Some
40 times you'll want to run other before_filters before that. They should then be
41 declared ahead of including this module.
79ded84 @dhh SSL requirement adds a declarative way of specifying that certain act…
dhh authored
42
43 Copyright (c) 2005 David Heinemeier Hansson, released under the MIT license
Something went wrong with that request. Please try again.