require 'auth' require 'p4_error' require 'p4_util' module HelixVersioningEngine class App < Sinatra::Base # The login command here is used in cases where the authentication source # is not the same as the p4d used as the backing instance. We'll generate # a host unlocked ticket using this method. post '/p4/:api/login' do user = params[:user] password = params[:password] # may be a p4 ticket if user.nil? or password.nil? fail P4Error.default_error('user or password is not set') end ticket = nil env['p4'] = P4Util.open_from_env(env) p4 = env['p4'] p4.user = user p4.password = password p4.connect ticket = Auth.ticket_from_login(p4) halt 403 if ticket.nil? {ticket: ticket }.to_json end end end