Orbit/app/controllers/saml_logins_controller.rb

35 lines
710 B
Ruby

class SamlLoginsController < ApplicationController
require "net/http"
require "uri"
require 'rexml/document'
include REXML
def index
if params[:wa] == "wsignoutcleanup1.0" #logout
redirect_to :root
else #login
@wresult = params[:wresult]
@wctx = params[:wctx]
@main_url = LIST[:sites][@wctx]['url']
@main_public_key = LIST[:sites][@wctx]['key']
@doc = REXML::Document.new @wresult
public_key = OpenSSL::PKey::RSA.new(@main_public_key)
encrypted_data = public_key.public_encrypt(@doc.elements["//saml:AttributeValue"].text)
redirect_to "http://#{@main_url}/user_login?" + { :wresult => encrypted_data }.to_param
end
end
end