From: <jh...@us...> - 2009-09-23 00:55:27
|
Revision: 96 http://etch.svn.sourceforge.net/etch/?rev=96&view=rev Author: jheiss Date: 2009-09-23 00:55:17 +0000 (Wed, 23 Sep 2009) Log Message: ----------- Upgrade from Rails 2.1.1 to Rails 2.3.4 Modified Paths: -------------- trunk/server/app/controllers/files_controller.rb trunk/server/config/environment.rb Added Paths: ----------- trunk/server/app/controllers/application_controller.rb Removed Paths: ------------- trunk/server/app/controllers/application.rb Deleted: trunk/server/app/controllers/application.rb =================================================================== --- trunk/server/app/controllers/application.rb 2009-09-23 00:54:12 UTC (rev 95) +++ trunk/server/app/controllers/application.rb 2009-09-23 00:55:17 UTC (rev 96) @@ -1,68 +0,0 @@ -require 'etchserver' - -# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers. - -class ApplicationController < ActionController::Base - helper :all # include all helpers, all the time - - # See ActionController::Base for details - # Uncomment this to filter the contents of submitted sensitive data parameters - # from your application log (in this case, all fields with names like "password"). - # filter_parameter_logging :password - - # Turn on the exception_notification plugin - # See environment.rb for the email address(s) to which exceptions are mailed - include ExceptionNotifiable - - # Pick a unique cookie name to distinguish our session data from others' - session :session_key => '_etch_session_id' - - # Verify that any changes are signed if the administrator has - # enabled authentication - before_filter :authenticate, :only => [:create, :update, :destroy] - - # This authentication system is targeted at etch clients. There should be - # an alternate authentication mechanism targeted at humans so that humans - # can interact with this service when authentication is enabled. - def authenticate - if Etch::Server.auth_enabled? - if request.headers['Authorization'] && - request.headers['Authorization'] =~ /^EtchSignature / - signature = request.headers['Authorization'].sub(/^EtchSignature /, '') - verified = false - begin - verified = Etch::Server.verify_message(request.raw_post, - signature, - params) - rescue Exception => e - logger.error e.message - logger.info e.backtrace.join("\n") if params[:debug] - response = e.message - response << e.backtrace.join("\n") if params[:debug] - render :text => response, :status => :unauthorized - end - else - logger.info "Authentication required, no authentication data found" - render :text => "Authentication required, no authentication data found", :status => :unauthorized - end - end - end - - # find and to_xml take their :include options in different formats - # find wants: - # :include => { :rack => { :datacenter_rack_assignment => :datacenter } } - # or this (which is what we use because it is easier to generate recursively) - # :include => { :rack => { :datacenter_rack_assignment => { :datacenter => {} } } } - # to_xml wants: - # :include => { :rack => { :include => { :datacenter_rack_assignment => { :include => { :datacenter => {} } } } } } - # This method takes the find format and returns the to_xml format - def convert_includes(includes) - includes.each do |key, value| - unless (value.nil? || value.blank?) - includes[key] = { :include => convert_includes(value) } - end - end - includes - end -end Copied: trunk/server/app/controllers/application_controller.rb (from rev 92, trunk/server/app/controllers/application.rb) =================================================================== --- trunk/server/app/controllers/application_controller.rb (rev 0) +++ trunk/server/app/controllers/application_controller.rb 2009-09-23 00:55:17 UTC (rev 96) @@ -0,0 +1,68 @@ +require 'etchserver' + +# Filters added to this controller apply to all controllers in the application. +# Likewise, all the methods added will be available for all controllers. + +class ApplicationController < ActionController::Base + helper :all # include all helpers, all the time + + # See ActionController::Base for details + # Uncomment this to filter the contents of submitted sensitive data parameters + # from your application log (in this case, all fields with names like "password"). + # filter_parameter_logging :password + + # Turn on the exception_notification plugin + # See environment.rb for the email address(s) to which exceptions are mailed + include ExceptionNotifiable + + # Pick a unique cookie name to distinguish our session data from others' + session :session_key => '_etch_session_id' + + # Verify that any changes are signed if the administrator has + # enabled authentication + before_filter :authenticate, :only => [:create, :update, :destroy] + + # This authentication system is targeted at etch clients. There should be + # an alternate authentication mechanism targeted at humans so that humans + # can interact with this service when authentication is enabled. + def authenticate + if Etch::Server.auth_enabled? + if request.headers['Authorization'] && + request.headers['Authorization'] =~ /^EtchSignature / + signature = request.headers['Authorization'].sub(/^EtchSignature /, '') + verified = false + begin + verified = Etch::Server.verify_message(request.raw_post, + signature, + params) + rescue Exception => e + logger.error e.message + logger.info e.backtrace.join("\n") if params[:debug] + response = e.message + response << e.backtrace.join("\n") if params[:debug] + render :text => response, :status => :unauthorized + end + else + logger.info "Authentication required, no authentication data found" + render :text => "Authentication required, no authentication data found", :status => :unauthorized + end + end + end + + # find and to_xml take their :include options in different formats + # find wants: + # :include => { :rack => { :datacenter_rack_assignment => :datacenter } } + # or this (which is what we use because it is easier to generate recursively) + # :include => { :rack => { :datacenter_rack_assignment => { :datacenter => {} } } } + # to_xml wants: + # :include => { :rack => { :include => { :datacenter_rack_assignment => { :include => { :datacenter => {} } } } } } + # This method takes the find format and returns the to_xml format + def convert_includes(includes) + includes.each do |key, value| + unless (value.nil? || value.blank?) + includes[key] = { :include => convert_includes(value) } + end + end + includes + end +end Modified: trunk/server/app/controllers/files_controller.rb =================================================================== --- trunk/server/app/controllers/files_controller.rb 2009-09-23 00:54:12 UTC (rev 95) +++ trunk/server/app/controllers/files_controller.rb 2009-09-23 00:55:17 UTC (rev 96) @@ -9,7 +9,12 @@ response = nil begin etchserver = Etch::Server.new(params[:facts], params[:tag], params[:debug]) - response = etchserver.generate(params[:files]) + # params[:files] is a hash of filename => hash_of_options + # The client runs the filename through CGI.escape in case it contains + # special characters. Older versions of Rails automatically decoded the + # filename, but as of Rails 2.3 we need to do it ourself. + files = params[:files].inject({}) { |h, (file, value)| h[CGI.unescape(file)] = value; h } + response = etchserver.generate(files) render :text => response rescue Exception => e logger.error e.message Modified: trunk/server/config/environment.rb =================================================================== --- trunk/server/config/environment.rb 2009-09-23 00:54:12 UTC (rev 95) +++ trunk/server/config/environment.rb 2009-09-23 00:55:17 UTC (rev 96) @@ -5,7 +5,7 @@ # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present -RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION +RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |