Module: ActionController::ForceSSL
- Extended by:
- ActiveSupport::Concern
- Includes:
- AbstractController::Callbacks
- Defined in:
- actionpack/lib/action_controller/metal/force_ssl.rb
Overview
This module is deprecated in favor of config.force_ssl
in your environment config file. This will ensure all endpoints not explicitly marked otherwise will have all communication served over HTTPS.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- ACTION_OPTIONS =
[:only, :except, :if, :unless]
- URL_OPTIONS =
[:protocol, :host, :domain, :subdomain, :port, :path]
- REDIRECT_OPTIONS =
[:status, :flash, :alert, :notice]
Constants included from ActiveSupport::Callbacks
ActiveSupport::Callbacks::CALLBACK_FILTER_TYPES
Instance Method Summary collapse
Methods included from ActiveSupport::Concern
append_features, class_methods, extended, included
Methods included from AbstractController::Callbacks
Methods included from ActiveSupport::Callbacks
Instance Method Details
#force_ssl_redirect(host_or_options = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'actionpack/lib/action_controller/metal/force_ssl.rb', line 37 def force_ssl_redirect( = nil) unless request.ssl? = { protocol: "https://", host: request.host, path: request.fullpath, status: :moved_permanently, } if .is_a?(Hash) .merge!() elsif [:host] = end secure_url = ActionDispatch::Http::URL.url_for(.slice(*URL_OPTIONS)) flash.keep if respond_to?(:flash) && request.respond_to?(:flash) redirect_to secure_url, .slice(*REDIRECT_OPTIONS) end end |