Background and installation



There are several different Perl modules that implement CAS. This guide reviews Perl AuthCAS . JA-SIG maintains a list of supported Perl clients. Perl AuthCAS works with older versions of Perl while other clients, such as Apache2::AuthCAS, require 5.8.8 or newer as well as additional modules that may or may not be installed.


Perl AuthCAS is installed on metro so if you are developing on metro you can call it by adding 

 

use AuthCAS;

 to your script. 

 

AuthCAS is also in CPAN so running

 perl -MCPAN -e 'install Auth::CAS'

will install the module.

 

You may also download the source and build it manually


Example



Here is a simple example of using GTLogin with Perl AuthCAS on metro

#!/usr/bin/perl# Load AuthCAS libraryuse AuthCAS;print "Content-type: text/html\n\n";# Initial configuration$ThisURL = 'http://classrooms.gatech.edu/cgi-bin/remedy/mycas.pl'; # The URL of your page$CASurl = 'https://login.gatech.edu/cas'; # URL of GT Login$CAfile = '/opt/local/src/apache_1.3.33/conf/ssl.crt/ca-bundle.crt'; # The location of the Certificate bundle on metro. Your location may vary,# Declare a CAS object with the above configuration$CASobject = new AuthCAS('casUrl' => $CASurl, 'CAFile' => $CAfile);# Check for a CAS ticket$GivenServiceTicket = ($ENV{QUERY_STRING} =~ /\bticket=([^?&\s]+)/s) ? $1 : undef;# If found then we have passed CAS. Save the GTAccount into a variable.if (defined $GivenServiceTicket) { $GTAccount = $CASobject->validateST($ThisURL, $GivenServiceTicket); # If we have a ticket but it is invalid then something went wrong. Save the error into a variable. if (!defined $GTAccount) { $StatusText = 'You have NOT been authenticated'; $StatusText = AuthCAS::get_errors() ; } } # If there is no ticket, send the user to GTLogin to get one...else { $LoginURL = $CASobject->getServerLoginURL($ThisURL); $StatusText = "Redirecting to $LoginURL ..."; $MetaTag = '<META HTTP-EQUIV=REFRESH CONTENT="0; URL=' . $LoginURL . '">';print $MetaTag;}# If we have a valid user, welcome them.if (defined $GTAccount) {$logoutURL = $CASobject->getServerLogoutURL($ThisURL);print "Welcome $GTAccount!<br><a href=\"$logoutURL\">Logout</a>";}# Otherwise, something went wrong. Print the explanation.else { print $StatusText; }