#!/usr/bin/perl use strict; use lib '/usr/local/ray/www/site_perl'; use Apache::Constants qw(:common); use CGI qw(:standard); use CGI::Carp; use LWP::UserAgent; my $cgi = new CGI; my %p = $cgi->Vars; $p{credential_0} =~ s/^\s+|\s+$//g; my $server= 'server_c'; my $domain= 'company.com'; ## Set protocol based on what the user wants ## some might use http my $protocol = 'http'; ## And for https... if ( $ENV{HTTP_REFERER} =~ /^https:/ ) { $protocol = 'https'; } ## This is the server that the user will be redirected to my $url = "$protocol://$server.$domain"; my $dest = '/users/'; my $creds = "credential_0=$p{credential_0}&credential_1=$p{credential_1}&destination=$dest"; my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 }); ## Post the credentials my $req = HTTP::Request->new(POST => "$url/LOGIN"); $req->content_type('application/x-www-form-urlencoded'); $req->content($creds); ## Get the response my $res = $ua->request($req); ## Change location to their server $res->header( 'Location' => "$url/users/" ); ## Print to browser print $res->as_string;