require 'pp' class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception before_action :validate_session, except: [ :nothing ] # TODO: use devise or rails or whatever to implement a real session system # for now just make hashes of data and store metadata by token @@sessions = {} rescue_from Exception do |exception| if Rails.env.development? error = {message:exception.message} error[:application_trace] = Rails.backtrace_cleaner.clean(exception.backtrace) error[:full_trace] = exception.backtrace puts error render :text => error, :status => 500 else render :text => "Internal server error.", :status => 500 end end def nothing render :nothing => 'true' end protected def json_request? request.format == 'application/json' end def validate_session puts "cookies[:hws_token]:" pp cookies[:hws_token] # look for the magic cookie session_key = cookies[:hws_token] @current_session = @@sessions[session_key] head 403 and return false if @current_session.nil? if @current_session[:expires] < DateTime.current puts 'Expiring session ' + @current_session @current_session = nil @@sessions.delete(session_key) redirect_to login, status: 403 and return false end # TODO: check other metadata end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 17271 | tjuricek | Remove deprecated Ruby implementation. | ||
//guest/perforce_software/helix-web-services/main/source/helix_web_services/mock_raymond/app/controllers/application_controller.rb | |||||
#2 | 17140 | tjuricek |
Integrating porting work from development branch. This work is now ready for testing/CD integration. |
||
#1 | 16072 | tjuricek |
Helix Cloud integration for Helix Sync services. This includes a "mock_raymond" rails application for keeping tabs on basic integration with Helix Cloud. We do not test against a live server. See integration history for more details. |
||
//guest/doug_scheirer/helix-web-services/main/source/helix_web_services/mock_raymond/app/controllers/application_controller.rb | |||||
#2 | 16024 | Doug Scheirer | Some cloud spec forking, got the mock_raymond to spin up in cloud testing, split normal vs cloud spec output | ||
#1 | 15851 | Doug Scheirer | mock raymond service, rails app development standin for the helix cloud webapp |