require 'securerandom' require 'P4' class AuthController < ApplicationController skip_before_action :verify_authenticity_token, except: [ :user ] before_action :validate_session, except: [ :login, :nothing ] # this is used as a dummy endpoint to validate they are authenticated def user render :json => @@sessions[cookies[:hws_token]] end def login render :nothing => true, status: 401 and return if params['user'].nil? || params['user']['name'].nil? || params['user']['password'].nil? p4ticket = nil # for funsies, auth to a perforce server begin p4 = P4.new p4.port = ENV['P4PORT'] || 'qaplay:1999' p4.user = params['user']['name'] p4.password = params['user']['password'] p4.charset = 'auto' p4.connect p4ticket = p4.run_login('-p') rescue P4Exception => e puts e.message render :nothing => true, status: 403 and return end # good to go, store the metadata and make a token token = SecureRandom.hex # TODO: add more metadata user_data = { :user => params['user']['name'], :expires => DateTime.current + 5.minutes, :p4ticket => p4ticket[0] } @@sessions[token] = user_data # done render :text => "hws_token=#{token}" end def logout puts params @@sessions.delete(session_key) render :nothing => 'true' 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/auth_controller.rb | |||||
#3 | 17140 | tjuricek |
Integrating porting work from development branch. This work is now ready for testing/CD integration. |
||
#2 | 17123 | tjuricek |
Helix Cloud interop with the local p4d was incorrect, since no charset was specified. Revised location of where we run the new Helix Sync submit spec, for some reason this breaks the Helix Cloud system. There's some dependencies between the initial add and the "remove" specs, so the new "add with description" test needs to come after the remove. |
||
#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/auth_controller.rb | |||||
#1 | 15851 | Doug Scheirer | mock raymond service, rails app development standin for the helix cloud webapp |