rails / ssl_requirement Goto Github PK
View Code? Open in Web Editor NEWNOTICE: official repository moved to https://github.com/retr0h/ssl_requirement
Home Page: http://rubyonrails.org
NOTICE: official repository moved to https://github.com/retr0h/ssl_requirement
Home Page: http://rubyonrails.org
SSL Requirement =============== SSL requirement adds a declarative way of specifying that certain actions should only be allowed to run under SSL, and if they're accessed without it, they should be redirected. Example: class ApplicationController < ActiveRecord::Base include SslRequirement end class AccountController < ApplicationController ssl_required :signup, :payment ssl_allowed :index def signup # Non-SSL access will be redirected to SSL end def payment # Non-SSL access will be redirected to SSL end def index # This action will work either with or without SSL end def other # SSL access will be redirected to non-SSL end end You can overwrite the protected method ssl_required? to rely on other things than just the declarative specification. Say, only premium accounts get SSL. P.S.: Beware when you include the SslRequirement module. At the time of inclusion, it'll add the before_filter that validates the declarations. Some times you'll want to run other before_filters before that. They should then be declared ahead of including this module. Copyright (c) 2005 David Heinemeier Hansson, released under the MIT license
Hey guys,
I was wondering if there is an easy way to force SSL on the entire app, without having to explicitly declare it in every controller?
Thanks so much!
Fer Martin
I am trying to replace bartt-ssl_requirement gem with ssl_requirement gem in my rails 4 app at that time I am facing this issue NoMethodError.
undefined method `disable_ssl_check=' for SslRequirement:Module (NoMethodError)
undefined method `read_inheritable_attribute'
def ssl_allowed?
(self.class.read_inheritable_attribute(:ssl_allowed_actions) || []).include?(action_name.to_sym)
end
read_inheritable_attribute and write_inheritable_array has been deprecated in rails 4
In the readme, shouldn't this be:
class ApplicationController < ActionController::Base
It may be helpful to others to update the notice to indicate that the latest version is available here: https://github.com/bartt/ssl_requirement
https://github.com/retr0h/ssl_requirement does not seem to exist anymore.
I was wondering where I can find the license for this package.
ssl_requirement's ssl_required doesn't work for "subfolder controllers", eg class Text::WriteController < ApplicationController ... located at /app/controllers/text.
Instead of using (sample for def index and def create):
ssl_required :index, :create
you can use this as a workaround:
def ssl_required?
return true if %w{index create}.any? {|a| a == params[:action]}
end
Getting this error when I am using 'ssl_requirement' with my Rails 4.0 and Ruby 2.0 application.
NoMethodError (undefined method read_inheritable_attribute' for SessionsController:Class): ssl_requirement (0.1.0) lib/ssl_requirement.rb:45:in
ssl_allowed?'
ssl_requirement (0.1.0) lib/ssl_requirement.rb:50:in ensure_proper_protocol' activesupport (4.0.0) lib/active_support/callbacks.rb:407:in
_run__3063776826992777902__process_action__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in run_callbacks' actionpack (4.0.0) lib/abstract_controller/callbacks.rb:17:in
process_action'
actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in
block in process_action'
maybe create a rails 3 branch that uses request.fullpath rather than request.request_uri?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.